Skip to content

A simple way to solve the problem of the command line #3

Description

@mezoni

Try it and maybe it will help you solve some of your problems.

This sample intended for your current requirements but you can easily add new commands and options and arguments.

#!/usr/bin/env dart

library serial_port.script;

import 'package:args_helper/args_helper.dart';
import 'package:serial_port/cli.dart' deferred as cli;
import 'package:serial_port/compiler.dart' deferred as compiler;
import 'package:yaml/yaml.dart' as yaml;

void main(List<String> arguments) {
  var configuration = yaml.loadYaml(_configuration);
  new ArgsHelper<Program>().run(arguments, configuration);
}

class Program {
  void compileCommand() {
    compiler.loadLibrary().then((_) {
      compiler.compile();
    });
  }

  void listCommand() {
    cli.loadLibrary().then((_) {
      cli.list();
    });
  }
}

String _configuration = '''
name: serial_port
description: Serial port
commands:  
  compile:    
    description: Compile "serial port"    
  list:
    description: List some values           
''';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions