Giter Club home page Giter Club logo

plexdata.argumentparser's Introduction

Plexdata Argument Parser

The Plexdata Argument Parser is a library that allows users to easily parse the command line arguments given to a program. The main feature of this library is that users only need to define their own class representing all possible command line arguments. Thereafter, each of the properties is tagged by an attribute which describes the kind of the expected command line argument.

At runtime an instance of this pre-defined class is consigned to the Plexdata Argument Parser together with the actual command line arguments. After the parsing procedure, the class contains the values that have been assigned by command line.

Another feature of the Plexdata Argument Parser is the possibility of an automated generation of the help text. For this purpose the pre-defined class is tagged by a suitable set of attributes that include all information needed to create the help text.

For an introduction see the Docs under https://akesseler.github.io/Plexdata.ArgumentParser/.

plexdata.argumentparser's People

Contributors

akesseler avatar

Stargazers

 avatar

Watchers

 avatar

plexdata.argumentparser's Issues

Parsing Custom classes

This would be neat to have

    public class WidthHeightXY
    {
        public int Width, Height, X, Y;
        public WidthHeightXY(int Width, int Height, int X, int Y) {
            this.Width = Width; this.Height = Height; this.X = X; this.Y = Y;
        }
        public WidthHeightXY(string input) {
            var splitted = Array.ConvertAll(input.Split(":"), int.Parse);
            Width = splitted[0]; Height = splitted[1]; X = splitted[2]; Y = splitted[3];
        }
        public override string ToString() {
            return $"{Width}:{Height}:{X}:{Y}";
        }
            [HelpSummary("Crop the device screen on the server. The values are expressed in the device natural orientation (typically, portrait for a phone, landscape for a tablet). Any --max-size value is computed on the cropped size.")]
            [OptionParameter(SolidLabel = "crop", BriefLabel = "c")]
            public WidthHeightXY Crop { get; set; }

absolute unix paths cant be passed as value

heyo, i just encountered this issue

--argument /home/x/somefile

results in an exception thrown here

cause by this line

else if (value.StartsWith(ParameterPrefixes.OtherPrefix))

wrongly interpreting the path as a parameter.

the same behaviour would also occur if i try to pass any string in as value that begins with -- or -

a possible fix might be to parse the parameters backwards? so if you encounter a /xyz you check if its a known option, and if not put it on the stack as a value or positional argument, then parse the one before it to see how to interpret the value. or alternatively just trust that the string following a parameter is supposed to be interpreted as value?

HelpSummary with VerbalParameter

The HelpSummary attribute cuts off any text longer than the generating width. This happens together with VerbalParameter.

Another wish on the list... Use HelpSummary content together with VerbalParameter instead of throwing an exception. Workaround: [HelpSummary(Options = "...")] would work at the moment.

Yet another issue... The formatting is broken when HelpSummary is used together with VerbalParameter and the help text is shorter than max line width..

Default value attribute

            [HelpSummary("Set the TCP port the client listens on. Default is 5555")]
            [OptionParameter(SolidLabel = "port", BriefLabel = "p", DefaultValue = 5555)]
            public ushort Port { get; set; }

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.