The complete solution for Dart command-line interfaces

Overview

commander.dart

Build Status License Dart

The complete solution for Dart command-line interfaces, inspired by node commander.js which created by tj.

Why

cause I don't like build the cli app with other exist lib.

those api are not graceful enough. so I want build a lib use like commander.js

it make you move cli tool from Nodejs easier.

This lib in developing. I can't make sure it work like expect even I have write many test cases.

Enjoy it!

Requirement

  • dart>=1.20.0

Supports

  • Windows
  • Linux
  • MacOS

Example

Option parsing

#!/usr/bin/env dart

import 'package:escli/escli.dart' show program;

void main(List<String> arguments){
  program
    ..name('test')
    ..version('1.2.0')
    ..description('test desc')
    ..usage(' [options]')
    ..option('-p, --peppers', 'Add peppers')
    ..option('-P, --pineapple', 'Add pineapple')
    ..option('-b, --bbq-sauce', 'Add bbq sauce')
    ..option('-c, --cheese [type]', 'Add the specified type of cheese [marble]');
  
  program.parseArgv(arguments);
  
  print('--peppers: ${program.$option["peppers"]}');
  print('--pineapple: ${program.$option["pineapple"]}');
  print('--bbq-sauce: ${program.$option["bbqSauce"]}');
  print('--cheese: ${program.$option["cheese"]}');
  
  print('enjoy it');
}

Coercion

import 'package:escli/escli.dart' show program;
void main(List<String> arguments) {
  parseInt(int n){
    print('--interger: $n');
  }
  parseFlow(num n){
    print('--float: $n');
  }
  range(val) {
    print('--float: $val');
  }

  list(val) {
    print('--list: $val');
  }

  collect(val) {
    print('--optional: $val');
  }

  increaseVerbosity(val) {
    print('--verbose: $val');
  }

  program
    ..name('test')
    ..version('1.2.0')
    ..description('test desc')
    ..usage(' [options]')
    ..option('-i, --integer ', 'An integer argument', parseInt)
    ..option('-f, --float ', 'A float argument', parseFlow)
    ..option('-l, --list ', 'A list', list)
    ..option('-o, --optional [value]', 'An optional value')
    ..option('-c, --collect [value]', 'A repeatable value', collect)
    ..option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)
    ..parseArgv(arguments);
}

Specify the argument syntax

import 'package:escli/escli.dart' show program;

void main(List<String> arguments){
  program
    ..version('0.0.1')
    ..command(' [env]')
    ..action((Map argv, Map options) {
    print(argv);
    print(options);
  });
  program.parseArgv(arguments);
}

Git-style sub-commands (Recommend)

import 'package:escli/escli.dart' show program;

void main(List<String> arguments) {
  program
    ..version('0.0.1');

  program
    .command('install [name]', 'install one or more packages')
    .action((Map argv, Map options) {

    });

  program
    .command('search [query]', 'search with optional query')
    .action((Map argv, Map options) {

    });
  
  program
    .command('list', 'list packages installed')
    .action((Map argv, Map options) {

    });
}

Automated -h, --help

$ gpmx -h

  Usage: gpmx  [options]

    Git Package Manager, make you manage the repository easier, Power by Dart

  Commands:
    ls|list              display the all repo.
    ad|add         clone repo into local dir.
    rm|remove            remove a repo.
    cl|clean             clean the temp/cache.
    rt|runtime           print the program runtime, useful for submit a issue.
    rl|relink            relink the base dir which contain repositories if you delete repository manually.
    ip|import       register a repository to GPM.

  Options:
    -V, --version      print the current version
    -h, --help         print the help info about 

Automated -V, --version

$ gpmx --version
0.0.1

Complete Demo

https://github.com/gpmer/gpm.dart

Test

./scripts/test

Contribute

git clone https://github.com/axetroy/commander.dart.git
cd ./commander.dart
pub get
./scripts/test

You can flow Contribute Guide

License

The MIT License

You might also like...

Unofficial search provider for Medium for dart/flutter apps.

medium_search Unofficial search provider for Medium that can be used in dart or flutter apps. This library provides you an easy way to get search resu

Jan 10, 2022

Making-form - A form design with dart programming and auto next facility

Making-form - A form design with dart programming and auto next facility

Making-form - A form design with dart programming and auto next facility

Nov 15, 2022

A dart package to display a horizontal bar of customisable toggle tabs. Supports iOS and Android.

A dart package to display a horizontal bar of customisable toggle tabs. Supports iOS and Android.

toggle_bar A dart package to display a horizontal bar of customisable toggle tabs. Supports iOS and Android. Installation Depend on it. dependencies:

Jul 13, 2022

Pure Dart and Flutter package for Android,IOS and Web

Pure Dart and Flutter package for Android,IOS and Web

Fancy Flutter Alert Dialog Pure Dart and Flutter package for Android,IOS and Web A flutter Package to show custom alert Dialog,you can choose between

Sep 23, 2022

Protofu is a Dart Command Line tool for generating your protobufs and included dependencies in one command.

ProtoFu - let me compile that for you ProtoFu exists to make working with protobufs easier. Gone are the days of downloading protoc and the dart proto

Oct 27, 2022

A command-line application provide an load optimization solution for flutter web

A command-line application provide an load optimization solution for flutter web

一个命令行工具,针对flutter web加载慢和缓存问题提供了一套解决方案。 功能 通过大文件分片和资源文件cdn化方式,优化flutter web页面加载慢问题。 通过资源文件hash化,解决浏览器强缓存导致功能无法更新问题。 开始 局部安装 dev_dependencies: flutte

Dec 29, 2022

High-level interfaces to Google Cloud Platform APIs

Google Cloud Platform support package (gcloud) The gcloud package provides a high level "idiomatic Dart" interface to some of the most widely used Goo

Dec 13, 2022

A Very Good Command Line Interface for Dart created by Very Good Ventures 🦄

A Very Good Command Line Interface for Dart created by Very Good Ventures 🦄

Very Good CLI Developed with 💙 by Very Good Ventures 🦄 A Very Good Command Line Interface for Dart. Installing $ dart pub global activate very_good_

Jan 8, 2023

A type-safe command-line parsing library for Dart

plade Plade is a type-safe CLI parsing library for Dart. Highlights Fully type-safe and null-safe. Support for a variety of different parsing styles (

Jan 1, 2022

Package your Flutter app into OS-specific bundles (.app, .exe, etc.) via Dart or the command line.

flutter_app_packager Package your Flutter app into OS-specific bundles (.app, .exe, etc.) via Dart or the command line. The flutter_app_packager sourc

Jan 8, 2023

Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations between routers

Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations between routers

UPROOT Uproot(uprt) is a multi-platform (Windows, MacOs, and Linux) command line utility written in Dart to convert a router's DHCP IP Reservations be

Jan 1, 2023

Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line.

flutter_distributor Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line. The flutter_distributor source

Dec 24, 2022

Bosun is a library for building organized command line applications in Dart.

Bosun A library for parsing CLI input and structuring CLI commands Features Structure CLI commands in a nice, uniform fashion. Parse args and flag inf

Oct 13, 2022

Arissounddart - a Command-line SoundSprite generator for Dart

SoundDart SoundDart is a Command-line SoundSprite generator for Dart. It require

Jan 9, 2022

A Nerolab Command Line Interface for Dart created by Nerolab

A Nerolab Command Line Interface for Dart created by Nerolab

Nerolab CLI Nerolab Command Line Interface for Dart. Special thanks to GroovinChip with groovin_cli and very_good_cli. Installing dart pub global acti

Jan 19, 2022

changelog.dart provides a library and a command-line application to manage in the correct way the git metadata to build the changelog between two release

changelog.dart provides a library and a command-line application to manage in the correct way the git metadata to build the changelog between two release

changelog.dart 🎯 changelog.dart: a collection of tools to manages in a fashion way a repository as maintainer. 🎯 Project Homepage Table of Content I

Dec 18, 2022

This is a command-line app written on dart language for flutter applications that will help you to generate some boilerplate code

dart-generator Manual installation: 1- generate a platform executable from code dart compile exe main.dart -o generator this will generate a new gene

Oct 26, 2022

Scaff is a simple command-line utility for generating Dart and Flutter components from template files.

Introduction Scaffold Generator for Dart and Flutter. scaff is a simple command-line utility for generating Dart and Flutter components from template

Jul 17, 2022

Interactive command line interface Couchbase Lite REPL utility built with the Dart

Interactive command line interface Couchbase Lite REPL utility built with the Dart

Couchbase Lite Dart CLI Interactive command line interface Couchbase Lite REPL utility built with the Dart programming language. This code uses the cb

Jul 20, 2022
Comments
  • Configure Renovate

    Configure Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    :vertical_traffic_light: To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • pubspec.yaml (pub)

    Configuration Summary

    Based on the default config's presets, Renovate will:

    • Start dependency updates only once this onboarding PR is merged
    • Separate major versions of dependencies into individual branches/PRs
    • Do not separate patch and minor upgrades into separate PRs for the same dependency
    • Upgrade to unstable versions only if the existing version is unstable
    • Raise PRs immediately (after branch is created)
    • If semantic commits detected, use semantic commit type fix for dependencies and chore for all others
    • Keep existing branches updated even when not scheduled
    • Disable automerging feature - wait for humans to merge all PRs
    • Ignore node_modules, bower_components, vendor and various test/tests directories
    • Update existing lock files only when package.json is modified
    • Autodetect whether to pin dependencies or maintain ranges
    • Rate limit PR creation to a maximum of two per hour
    • Limit to maximum 20 open PRs at any time
    • Group known monorepo packages together
    • Use curated list of recommended non-monorepo package groupings

    :abcd: Would you like to change the way Renovate is upgrading your dependencies? Simply edit the renovate.json in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.


    You have configured Renovate to use branch master as base branch.

    What to Expect

    It looks like your repository dependencies are already up-to-date and no Pull Requests will be necessary right away.


    :question: Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 1
Owner
Axetroy
A non-professional, self-study open-source fool-stack developer. Focus on Rust & Golang & Typescript.
Axetroy
A widget displaying children in a line with an overflow indicator at the end if there is not enough space.

overflow_view A widget displaying children in a line with an overflow indicator at the end if there is not enough space. Features Renders children hor

Romain Rastel 153 Dec 19, 2022
A package for flutter to use alert and toast within one line code.

easy_alert A package for flutter to use alert and toast within one line code. Getting Started Add easy_alert: to your pubspec.yaml, and run flutt

null 34 Jun 25, 2021
A Flutter library to add the Common effect (line, bubble, dot ...) of tab indicator.

flutter_tab_indicator A Flutter library to add the Common effect (line, bubble, dot ...) of tab indicator. Showcases Installation Showcases Showcases

CrabMan 14 Jun 19, 2022
React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.

English | Português Flutter Hooks A Flutter implementation of React hooks: https://medium.com/@dan_abramov/making-sense-of-react-hooks-fdbde8803889 Ho

Remi Rousselet 2.6k Dec 29, 2022
Powerful Complete and Beautiful Search Component for Flutter

A highly customizable search component to accelerate your development. Overview There are many search or search components for Flutter, however this o

Tiagosito 31 Jul 27, 2022
RoundedLoadingButton is a Flutter package with a simple implementation of an animated loading button, complete with success and error animations.

rounded_loading_button RoundedLoadingButton is a Flutter package with a simple implementation of an animated loading button, complete with success and

Chris Edgington 223 Jan 4, 2023
A light-weight Emoji 📦 for Dart & Flutter with all up-to-date emojis written in pure Dart 😄 . Made from 💯% ☕ with ❤️!

dart_emoji ?? A light-weight Emoji ?? for Dart & Flutter with all up-to-date emojis written in pure Dart ?? . Made from ?? % ☕ with ❤️ ! This is a for

Gatch 18 Mar 22, 2022
Custom widgets and utils using Flutter framework widgets and Dart language

reuse_widgets_and_utils The custom widgets and utils using Flutter framework widgets and Dart programming language. Getting Started This project is a

null 1 Oct 29, 2021
Package ANAlysis for Dart

A library for analyzing Dart packages. It invokes executables from the Dart SDK (or from the Flutter SDK if the package uses Flutter). Reports are cre

Dart 151 Dec 30, 2022
Flutter package: Easy and powerful internationalization using Dart extensions.

i18n_extension Non-boilerplate Translation and Internationalization (i18n) for Flutter Start with a widget with some text in it: Text("Hello, how are

Marcelo Glasberg 262 Dec 29, 2022