fclp / fluent-command-line-parser

A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface
Other
533 stars 86 forks source link

how can i parse params like "dosomething.exe aaa --disable-background" #77

Open ysunf opened 7 years ago

ysunf commented 7 years ago

i can see the usage for params with short name or long name, but how about the params without names? For example, the chrome, startup with "chrome.exe www.bing.com --disable-background-networking" or maybe "chrome.exe --disable-background-networking www.bing.com --disable-component-update"? Thanks for your help!

aguarino77 commented 7 years ago

Why don't you just parse from index 1 like:

var result = p.Parse(args.Skip(1).ToArray());
siywilliams commented 7 years ago

Better support for this in 1.5, see https://github.com/fclp/fluent-command-line-parser/issues/89

fclp.Setup(arg => arg.Url)
      .As("url")
      .UseForOrphanArguments(); // any leading values with no option are captured for this option

fclp.Setup(arg => arg.DisableBackgroundNetworking)
      .As("disable-background-networking);

fclp.Parse(args);

// fclp.Object.Url will now contain "www.bing.com"

Which supports your chrome.exe www.bing.com --disable-background-networking example.

super!