Args simple - A simple argument parser and handler, integrated with JSON and dart

Overview

args_simple

pub package Null Safety Codecov CI GitHub Tag New Commits Last Commits Pull Requests Code size License

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> _args) {
  var args = ArgsSimple.parse(_args);

  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.

License

Apache License - Version 2.0

You might also like...

From JSON to Dart Advanced

From JSON to Dart Advanced

From JSON to Dart Advanced Table of Contents Features Convert from clipboard Convert from selection Convert from clipboard to code generation Convert

Dec 17, 2022

This package allows programmers to annotate Dart objects in order to Serialize / Deserialize them to / from JSON

This package allows programmers to annotate Dart objects in order to Serialize / Deserialize them to / from JSON. Why? Compatible with all target plat

Jan 6, 2023

A generator to create config class from json files that support many environments

A generator to create config class from json files that support many environments. Motivation If you use a json file to config your applications, perp

Oct 9, 2021

A flutter package that allows you to transform your excel to json

excel_to_json A package that allows you to transform your excel to the following format: Excel To JSON Getting Started At current the package allows y

Nov 7, 2022

library to help you create database on local memory, support json local database inspired by lowdb

Licensed Licensed under the MIT License http://opensource.org/licenses/MIT. SPDX-License-Identifier: MIT Copyright (c) 2021 Azkadev http://github.c

Oct 17, 2022

A flutter application , that create dynamic forms from json data

checktyper A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Aug 23, 2022

Generates utilities to aid in serializing to/from JSON.

Provides Dart Build System builders for handling JSON. json_serializable Package: https://pub.dev/packages/json_serializable Source code The core pack

Jan 8, 2023

A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

Oct 26, 2022

Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.

Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.

Jan 2, 2023
Releases(1.0.0)
Owner
Graciliano Monteiro Passos
Graciliano Monteiro Passos
JSON API parser for Flutter

Flutter Japx - JSON:API Decoder/Encoder Lightweight [JSON:API][1] parser that flattens complex [JSON:API][1] structure and turns it into simple JSON a

Infinum 23 Dec 20, 2022
A simple package to help does handler with countries in Flutter

It's a simple package to help does handler with countries in [Dart] language and [Flutter] Framework. Usage Countries class Can access all countries s

Leonardo Rosa 1 Feb 20, 2022
Dart phone number parser, based on libphonenumber and PhoneNumberKit.

Dart library for parsing phone numbers. Inspired by Google's libphonenumber and PhoneNumberKit for ios.

cedvdb 39 Dec 31, 2022
Dart phone number parser, based on libphonenumber and PhoneNumberKit.

Phone Numbers Parser Dart library for parsing phone numbers. Inspired by Google's libphonenumber and PhoneNumberKit for ios. The advantage of this lib

cedvdb 39 Dec 31, 2022
A Gura parser implementation for Dart

Gura Dart parser This repository contains the implementation of a Gura configuration format parser for Dart, written in pure Dart. (Compliant with spe

Zack Campbell 4 Aug 2, 2021
Provides null-safety implementation to simplify JSON data handling by adding extension method to JSON object

Lazy JSON Provides null-safety implementation to simplify JSON data handling by adding extension method to JSON object and JSON array. Getting started

Kinnara Digital Studio 0 Oct 27, 2021
Parser tool is a real-time compiler and runtime engine for strongly typed PEG parsers

parser_tool Version 0.1.1 (BETA) Parser tool is a real-time compiler and runtime engine for strongly typed PEG parsers. Parser tool contains libraries

null 6 Jun 28, 2021
An auto mapper for Dart. It allows mapping objects of different classes automatically and manually using JSON serialization.

AutoMapper for Dart An auto mapper for Dart. It allows mapping objects of different classes automatically and manually using JSON serialization. Examp

Leynier Gutiérrez González 7 Aug 24, 2022
A CLI tool to help generate dart classes from json returned from API

Json 2 Dart Command line utility Important note There is already a package called json2dart so this package will be called json2dartc ! This project w

Adib Mohsin 38 Oct 5, 2022
Cache json map to local file with Dart:io. Read file with sync api.

local_cache_sync 一个非常简单易用的Flutter本地储存库,适用于在本地储存一列轻量数据(例如用户保存在本地的设备信息,或者缓存一系列用户信息)。 local_cache_sync的所有方法都是同步,而不是异步的。这意味着你不需要使用await就可以获取数据。在flutter中,这

null 16 Jun 24, 2022