GithubHelp home page GithubHelp logo

yacp's Introduction

YACP

Yet another command parser...but simple one.

Glimpse

YACP is not powerful.

Supported types

  • string
  • int, int?
  • double, double?
  • bool
  • List, Array, IEnumerable of int, double and string

Expected syntax

Unlike other command parsers, YACP is not dedicatedly design for a command line app, and it also does not strictly follow the rule of POSIX command line. YACP needs a raw input command and a CLR typed entity (class, record, struct...etc), the CLR type uses diverse attribute to represent the command.

Here is a very standard expected command for YACP: /help -a1 p1 -a2 222 -a3, and a very standard command entity:

[Command("help", "h", Prefix = "/")]
class Help
{
    [Argument("-a1")]
    public string P1 { get; set; }

    [Argument("-a2")]
    public int P2 { get; set; }

    [Argument("-a3")]
    public bool P3 { get; set; }
}
  • /help: used for identify if a string is a command, and it consists of 2 segments: prefix and names, which means you can have many names for a command, suchlike /h and /help are equivalent.
  • -a1...-a2...-a3: they are arguments identifiers, multiple arguments identifiers is also supported in YACP, noticeablly a argument identifier is simply consists of a string instead of a combination of prefix and names like above.
  • ...p1...222...: parameters can have various types, here, p1 is considered as a string, 222 is an int, but for -a3, which supposed to be a bool, won't have a value but up to whether it exists to be true or false.

There's also some tricks in YACP, for an example: /h foo bar far boo, apparently it's an invalid POSIX command but it can be entitized to following entity in YACP:

[Command("help", "h", Prefix = "/")]
class Help
{
    [Argument("-a1", IsDefault = true)]
    public string P1 { get; set; }
}

Besides IsDefault, there's also other tricks like DefaultValue and IsRequired. Most of time, they cannot be stand together.

yacp's People

Contributors

kyocius avatar sinoahpx avatar

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.