coffee_cli 0.3.0 copy "coffee_cli: ^0.3.0" to clipboard
coffee_cli: ^0.3.0 copied to clipboard

outdatedDart 1 only

Easy way to create interactive command line application.

coffee_cli #

Easy way to create interactive command line application.

  • Parameter your cli with automatic usage
  • Ask question to user, with defautValue and allowed value parametrable
  • termcaps interaction for choice of allowed parameter

Usage #

Import

import 'package:coffee_cli/coffee_cli.dart';

2 differents usage

Extends CoffeeCli class #

class MyCli extends CoffeeCli {
  @CoffeeCommand(help: "Command usage")
  void command(String value, @CoffeeParameter(defaultValue: 42.42) double otherValue) {
    print(value);
    print(otherValue);
  }
  
  @CoffeeCommand(help: "Command usage")
  void otherCommand(@CoffeeParameter(allowed: const ["foo", "bar", "42"]) String value) {
    print(value);
  }

  @override
  usage() {
    print(outputGray("My awesome cli.", level: 0.5));
    super.usage();
  }
}
main(List<String> args) {
  return new MyCli().execute(args);
}

Use addCommand function #

Define a function to call

myFunction(String value, @CoffeeParameter(defaultValue: 42.42) double otherValue) {
  print(value);
  print(otherValue);
}

Define the cli

main(List<String> args) {
 return new CoffeeCli()
    ..addCommand("command", const CoffeeCommand(function: myFunction))
    ..execute(args);
}

Example #

Fork of cupid #

0
likes
40
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

Easy way to create interactive command line application.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

ansicolor, args, console, resource, stack_trace, worker

More

Packages that depend on coffee_cli