Click here to Skip to main content
10,500,000 members (51,264 online)
   

C#

 
AnswerRe: Shapefile Creations Pin
Dave Kreskowiak8-Feb-13 19:29
mvpDave Kreskowiak8-Feb-13 19:29 
GeneralRe: Shapefile Creations Pin
allasanthosh8-Feb-13 19:38
memberallasanthosh8-Feb-13 19:38 
GeneralRe: Shapefile Creations Pin
Dave Kreskowiak9-Feb-13 4:33
mvpDave Kreskowiak9-Feb-13 4:33 
QuestionCross threaded operations Pin
MAW308-Feb-13 12:23
memberMAW308-Feb-13 12:23 
AnswerRe: Cross threaded operations Pin
jibesh8-Feb-13 13:40
memberjibesh8-Feb-13 13:40 
GeneralRe: Cross threaded operations Pin
MAW308-Feb-13 16:25
memberMAW308-Feb-13 16:25 
GeneralRe: Cross threaded operations Pin
Dave Kreskowiak8-Feb-13 19:31
mvpDave Kreskowiak8-Feb-13 19:31 
Questionlibrary for command-line parameters Pin
lukeer8-Feb-13 4:06
memberlukeer8-Feb-13 4:06 
Hello Experts,

one of the console applications I wrote is about to get modified to do a similar job to the one it was first designed to do.

Its command-line parameters parsing works. But I never have been really happy with it. This example
tool.exe SetDo FirstLed On
should make an attached device switch its first LED on, obvisously. And it does so.

What bothers me is that SetDo has to be the first parameter, FirstLed the second and On the third. No way for the user to put an option before SetDo.

Since the modifications will change the possible actions anyway, I thought of finding a more standard library instead of using my own parsing.

First I checked the GNU getopt .NET port[^] and found using it horrible. You have to specify a format string, only for one-character options and a switch statement that matches the format string. Then you can attach long options that use a short option to determine what action they trigger.
That approach appears to be inspired by sprintf's format string[^], which we all know about and that it works. It just is so unintuitive to use from a programmer's point of view.

My second try was Mono.Options[^]. It doesn't require a format string. You just have to fill a generic list with one object per supported command. Short and long option names are supported in the object's constructor, along with a description of the command (for the auto-generated help screen) and a method to call during runtime.

Now I recognize that there's still a lot of work to do by hand since not all my options are boolean switches. The example I gave above uses two enumerations, one that holds all possible digital outputs to manipulate, the other for the state that should be the result of the manipulation. It doesn't look like there is an easy way to get that into the auto-generated help file, nor that the parser can handle situations like "Option A must preceed one of enum B's values followed by enum C's values", does it?


Does anyone know of a command-parsing library suitable for that?
Or should I rather tweak the working one into having my options position-independent?

Ciao,


luker

AnswerRe: library for command-line parameters Pin
PIEBALDconsult8-Feb-13 4:42
memberPIEBALDconsult8-Feb-13 4:42 
AnswerRe: library for command-line parameters Pin
PIEBALDconsult8-Feb-13 15:08
memberPIEBALDconsult8-Feb-13 15:08 
GeneralRe: library for command-line parameters Pin
Dave Kreskowiak8-Feb-13 15:11
mvpDave Kreskowiak8-Feb-13 15:11 
GeneralRe: library for command-line parameters Pin
PIEBALDconsult8-Feb-13 15:21
memberPIEBALDconsult8-Feb-13 15:21 
GeneralRe: library for command-line parameters Pin
Dave Kreskowiak8-Feb-13 16:15
mvpDave Kreskowiak8-Feb-13 16:15 
GeneralRe: library for command-line parameters Pin
PIEBALDconsult8-Feb-13 17:18
memberPIEBALDconsult8-Feb-13 17:18 
GeneralRe: library for command-line parameters Pin
Dave Kreskowiak8-Feb-13 19:45
mvpDave Kreskowiak8-Feb-13 19:45 
Question3D C# windows from Pin
taufiki8-Feb-13 1:04
membertaufiki8-Feb-13 1:04 
AnswerRe: 3D C# windows from Pin
DaveyM698-Feb-13 1:12
mentorDaveyM698-Feb-13 1:12 
AnswerRe: 3D C# windows from Pin
Pete O'Hanlon8-Feb-13 1:36
protectorPete O'Hanlon8-Feb-13 1:36 
AnswerRe: 3D C# windows from Pin
Amir Mohammad Nasrollahi29-Jul-13 23:27
professionalAmir Mohammad Nasrollahi29-Jul-13 23:27 
QuestionStoring folderBrowser.SelectedPath in a String Variable Pin
ASPnoob8-Feb-13 0:56
memberASPnoob8-Feb-13 0:56 
NewsRe: Storing folderBrowser.SelectedPath in a String Variable Pin
Eddy Vluggen8-Feb-13 1:28
mvpEddy Vluggen8-Feb-13 1:28 
GeneralRe: Storing folderBrowser.SelectedPath in a String Variable Pin
Dave Kreskowiak8-Feb-13 3:35
mvpDave Kreskowiak8-Feb-13 3:35 
AnswerRe: Storing folderBrowser.SelectedPath in a String Variable Pin
Eddy Vluggen8-Feb-13 1:29
mvpEddy Vluggen8-Feb-13 1:29 
AnswerRe: Storing folderBrowser.SelectedPath in a String Variable Pin
Dave Kreskowiak8-Feb-13 3:45
mvpDave Kreskowiak8-Feb-13 3:45 
GeneralRe: Storing folderBrowser.SelectedPath in a String Variable Pin
ASPnoob8-Feb-13 8:28
memberASPnoob8-Feb-13 8:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 29 Apr 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid