args_simple 1.1.0 args_simple: ^1.1.0 copied to clipboard
a simple argument parser and handler, integrated with JSON and dart:io.
args_simple #
A simple argument parser and handler, integrated with JSON and dart:io.
API Documentation #
See the API Documentation for a full list of functions, classes and extension.
Usage #
import 'dart:io';
import 'package:args_simple/args_simple_io.dart';
/// Examples of valid values for the parameter `args`:
///
/// - `/path/config.json --port 81 -verbose`
/// - `/path/config.json -verbose --sys-config /my/sys-config-dir`
/// - `/path/config.json root`
void main(List<String> argsOrig) {
var args = ArgsSimple.parse(argsOrig);
if (args.isEmpty) {
print(
'USAGE: [%configFile.json] [%user] [--port] [--sys-config %systemConfig] [-verbose]');
exit(0);
}
// Argument #0 is a JSON `File`:
var config = args.argumentMatches(0, RegExp(r'.json$'))
? args.argumentAsFileContentJSON(0)!
: {};
// Argument #1 is an optional `String`, with `guest` as default:
var user = args.argumentAsString(1, 'guest');
// Option `sys-config` is a `Directory`, with `/default/sys-config-dir` as default:
var systemConfigDir = args.optionAsDirectory(
'sys-config', Directory('/default/sys-config-dir'))!;
// Option `--port` is an `int`, with 8080 as default:
var port = args.optionAsInt('port', 8080);
// Check for flag `-verbose`:
var verbose = args.flag('verbose');
if (verbose) {
print('-- Config: $config');
print('-- User: $user');
print('-- System-Config Dir: $systemConfigDir');
print('-- Port: $port');
print('-- Verbose: $verbose');
print(args);
}
}
Source #
The official source code is hosted @ GitHub:
Features and bugs #
Please file feature requests and bugs at the issue tracker.
Contribution #
Any help from the open-source community is always welcome and needed:
- Found an issue?
- Please fill a bug report with details.
- Wish a feature?
- Open a feature request with use cases.
- Are you using and liking the project?
- Promote the project: create an article, do a post or make a donation.
- Are you a developer?
- Fix a bug and send a pull request.
- Implement a new feature, like other training algorithms and activation functions.
- Improve the Unit Tests.
- Have you already helped in any way?
- Many thanks from me, the contributors and everybody that uses this project!
If you donate 1 hour of your time, you can contribute a lot, because others will do the same, just be part and start with your 1 hour.
Author #
Graciliano M. Passos: gmpassos@GitHub.