Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cannot parse "1" #797

Copy link
Copy link
@yevheniia-alikberova

Description

@yevheniia-alikberova
Issue body actions

E.g. "--KEEP_ALIVE_OPTION=1".

This treats by the parser as no value:
Option 'keep_alive_option" has no value.
Required option 'keep_alive_option' is missing.

public class KeepAliveOptions
    {
        [Option(Required = true)]
        public string KEEP_ALIVE_OPTION { get; set; }
        [Option(Required = true)]
        public string LOGIN_URL { get; set; }
        [Option(Required = true)]
        public string ADVISOR_PASSWORD { get; set; }
        [Option(Required = true)]
        public string COMPANY_NUMBER { get; set; }
        [Option(Required = true)]
        public string OUT_DIR { get; set; }
        [Option(Required = true)]
        public string UserID { get; set; }
        [Option(Required = true)]
        public string Password { get; set; }
    }
public ParserResult<T> Parse<T>(string[] args) where T : IScriptOptions
        {
            Parser parser = new(s =>
            {
                s.CaseSensitive = false;
                s.IgnoreUnknownArguments = true;
                s.HelpWriter = Parser.Default.Settings.HelpWriter;
            });

            var scriptOptions = new List<string>();

            for (int i = 0; i < args.Length; i++)
            {
                string option = $"--{args[i].TrimStart('/')}";

                scriptOptions.Add(option);
            }

            return parser.ParseArguments<T>(scriptOptions);
        }
var result = Parse<KeepAliveOptions>(args)
                    .WithParsed(keepAliveOptions => options = keepAliveOptions)

Tried to change KEEP_ALIVE_OPTION type to int, it doesn't change anything

Fiddle: https://dotnetfiddle.net/vbujQc

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.