coffee_cli 0.3.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 37

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

Changelog

0.3.1

  • Better usage
  • Fix some bug on questions

0.3.0

  • When allowed is provide in a parameter, the cli provide an interactive chooser of available parameter

###Breaking Change

  • Construction of the cli has no change, you can now:
    • create a class extending CoffeeCli and annotate you function
    • instanciate CoffeeCli and use addCommand

see README

0.2.1

  • Fix various bugs

0.2.0

###Breaking Change

  • CoffeeParameter
    • possibleValues in CoffeeParameter change by allowed
    • bool parameter are no define as a flag
  • CoffeeCommand
    • command rename by executable
    • subcommands rename by commands
  • Can add CoffeeCommand as subcommand of an other CoffeeCommand
  • Better usage

0.1.1

Fix usage

0.1.0

Easy way to create interactive command line application

example/main.dart

// Copyright (c) 2016, <your name>. All rights reserved. Use of this source code

// is governed by a BSD-style license that can be found in the LICENSE file.
import 'package:coffee_cli/coffee_cli.dart';

class PolymerElementGenerator extends CoffeeCli {
  static const _cliHelp = "Polyce element, create and manage Polymer Elements.";
  static const _nameHelp = "Name of your element";
  static const _outputHelp = "Where would you like to create this element";
  static const _autonotifyHelp = "Whould you like to use polymer_autonotify";

  static CoffeeQuestion _questionOutputElement(CoffeeQuestion original) {
    return new CoffeeQuestion(_outputHelp, defaultValue: "./");
  }

  @CoffeeCommand()
  void create(@CoffeeParameter(help: _nameHelp, question: _nameHelp) String name,
      {@CoffeeParameter(help: _outputHelp, defineQuestion: _questionOutputElement) String output,
      @CoffeeParameter(help: _outputHelp, question: _autonotifyHelp) bool autonotify: true}) {
    print(name);
  }

  @override
  usage() {
    print(outputGray(_cliHelp, level: 0.5));
    super.usage();
  }
}

class PolyceCli extends CoffeeCli {
  @CoffeeCommand(help: "Element command usage")
  CoffeeCli element = new PolymerElementGenerator();

  @CoffeeCommand(help: "Init command usage")
  void init() {}

  @CoffeeCommand(help: "Toto command usage")
  void toto(@CoffeeParameter(allowed: const ["truc", "titi", "tata"]) String test) {}

  @override
  usage() {
    print(outputGray("Polyce cli, create and manage Polymer Dart Application.", level: 0.5));
    super.usage();
  }
}

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

main(List<String> args) {
  return new PolyceCli().execute(args);
}

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  coffee_cli: "^0.3.1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:coffee_cli/coffee_cli.dart';
        
Version Uploaded Documentation Archive
0.3.1 Jun 17, 2016 Go to the documentation of coffee_cli 0.3.1 Download coffee_cli 0.3.1 archive
0.3.0 Jun 13, 2016 Go to the documentation of coffee_cli 0.3.0 Download coffee_cli 0.3.0 archive
0.2.1 Jun 3, 2016 Go to the documentation of coffee_cli 0.2.1 Download coffee_cli 0.2.1 archive
0.2.0 Jun 2, 2016 Go to the documentation of coffee_cli 0.2.0 Download coffee_cli 0.2.0 archive
0.1.1 Jun 2, 2016 Go to the documentation of coffee_cli 0.1.1 Download coffee_cli 0.1.1 archive
0.1.0 Jun 2, 2016 Go to the documentation of coffee_cli 0.1.0 Download coffee_cli 0.1.0 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
37 / 100
Overall score:
Weighted score of the above. [more]
37

Platforms

Detected platforms: other

Primary library: package:coffee_cli/coffee_cli.dart with components: io, mirrors.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
ansicolor ^0.0.9 0.0.9
args ^0.13.4+2 0.13.7 1.3.0
console ^2.2.3 2.2.4
resource ^1.1.0 1.1.0 2.1.2
stack_trace >=1.3.3 <2.0.0 1.9.1
worker ^0.5.0 0.5.0
Transitive dependencies
matcher 0.12.1+4
path 1.5.1
quiver 0.22.0 0.28.0
typed_data 1.1.5
vector_math 1.4.7 2.0.5
Dev dependencies
test >=0.12.0 <0.13.0
testcase >=0.1.0 <0.2.0