Git Product home page Git Product logo

klash's People

Contributors

dustbyte avatar mota avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

klash's Issues

Handle type conversion when a specific interface is implemented

In order to facilitate custom type handling within a klashed structure, implement a check on a specific interface and if that type responds to this interface, then extract its converted value by calling the method of the interface.

The interface will be of the form:

type Convertible interface {
    FromString(stringval string) error
}

And the type implementing this Method should fill itself based on the string value.

Note: If a structure is provided and implements this interface, it is no longer considered as a subcommand, see #5

Group arguments

Allow via tags to make an argument depending on another one. The dependency is not mutual.

Tag spec: klash-group:"arg1,arg2"

The field name cases are not important.

Add tag shortcuts

Standard klash tags have very long names, which can be unconvenient when reading code.

Provide shortcuts over tags to allow more consive parameter tweaking with klash.

Handle exclusion

Handle exclusion via tags. The exclusion is not mutual.

Tag spec: klash-exclude:"arg1,arg2..."

The field name cases are not important.

Allow subparsing via structure types

If a structure type field responding to a defined interface is present within the arguments structure, this field is therefore considered as an "automatic" subcommand (compared to manual that plays with the stop behavior).

When encountered and if matching the program's arguments, the interface's function is executed when argument parsing is finised and the leftovers are parsed against this structure, and so on recursively (that is, a first level subcommand is not executed when one of its fields also responds this interface).

The substructure must respond the following interface:

type Command interface {
    Launch(parameters interface{}, leftover []string)
}
  • parameters hold a pointer to the root parameters structure.
  • leftover holds a list of remaining positional arguments

Allow argument aliasing

Allow via tags to provide an aliased name for the argument.

Tag spec: klash-alias:"othername"

Manage help and usage

Make klash handle automatically help and print usage on error or when the -h/--help option is provided and non-positional parsing is not stopped

Provide a way to add an help message to fields via tags

Tag spec: klash-help:"Help message"

Mark arguments as positional

Allow to mark arguments to be marked as positional.

In this case, the order of declaration of fields in the structure is significant and leftovers produce and error.
Another rule is that only the last positional field can be of slice type, in this case it stores every positional argument provided.

Tag spec: klash-positional:"true"

handle assignation

For the moment, only non-positional arguments followed by another argument are taken into account. Provide the --argument=value behavior.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.