Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NConsoler produces error when not correctly mapping command-line arguments to registered parameters? #7

Open
GoogleCodeExporter opened this issue Apr 16, 2015 · 12 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Set up action method to take one required string parameter ("StringParam"), 
one required int parameter ("IntParam"), 
and one optional bool parameter ("BoolParam")

2. Compile the program.

3. Run the program with no command-line parameters. NConsoler will produce
the following message:

 "usage: program StringParam IntParam [/BoolParam]\r\n" + 
            "    StringParam    <explanation>\r\n" + 
            "    IntParam      <explanation>\r\n" + 
            "    [/BoolParam]  <explanation>\r\n";


4. Call the program with just the first (string) and third (bool)
parameters:  program.exe StringParam /BoolParam

NConsoler will return an error:  Could not convert "/BoolParam" to integer


What is the expected output? What do you see instead?

I would expect NConsoler to map "/BoolParam" to the "BoolParam" parameter,
recognize that IntParam was not specified, and produce the "Not all
required parameters are set" message.  Instead, I see that NConsoler is
mapping the third, optional parameter (BoolParam) to the second required
parameter (IntParam), and producing an error while trying to convert it to int.


What version of the product are you using? On what operating system?

1.0 on XP Pro SP3.

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 7 Oct 2009 at 2:46

@GoogleCodeExporter
Copy link
Author

Ok, interesting idea, but what do you expect if we would have two string params?

Original comment by [email protected] on 8 Oct 2009 at 7:15

@GoogleCodeExporter
Copy link
Author

For 

[Required] string name, [Optional("Male")] string gender

program.exe stew /gender

I would expect that "/gender" would get matched against the gender param since 
the
names match.


For 

[Required] string name, [Required] string gender

program.exe stew male

I would expect each command-line argument to be matched positionally.


Am I interpreting the design wrong?   :)

Original comment by [email protected] on 8 Oct 2009 at 7:31

@GoogleCodeExporter
Copy link
Author

No, I mean 

[Required] string name, [Required] string city, [Optional("Male")] string gender

program.exe stew /gender:female

In this case city = "/gender:female" and gender = "Male"

Original comment by [email protected] on 8 Oct 2009 at 7:44

@GoogleCodeExporter
Copy link
Author

For that example, I would expect the framework to match "/gender" to "gender" 
based
on name, and produce an error message stating that the required parameter 
"city" was
not supplied.


Original comment by [email protected] on 8 Oct 2009 at 8:14

@GoogleCodeExporter
Copy link
Author

And if someone wants to pass such strange argument as "/gender:female" to a 
required
parameter we need to implement some kind of escaping and pass \/gender:female 
then

Original comment by [email protected] on 9 Oct 2009 at 8:03

@GoogleCodeExporter
Copy link
Author

Assuming there is no optional parameter named "gender" in that scenario, then 
could
you just resolve the parameter positionally and require that key:value pairs be
quoted and force the parsing responsibility onto the [Action] method?

E.g.
[Required] string name, [Required] string description

program.exe mary "gender:female"


Original comment by [email protected] on 9 Oct 2009 at 8:04

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 10 Nov 2010 at 9:47

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 10 Nov 2010 at 10:08

  • Added labels: Milestone-Release2.0

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 10 Nov 2010 at 10:08

  • Added labels: Milestone-Release-2.0
  • Removed labels: Milestone-Release2.0

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 10 Nov 2010 at 10:10

  • Added labels: Milestone-Backlog
  • Removed labels: Milestone-Release-2.0

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 23 Nov 2010 at 4:17

  • Added labels: Milestone-Release2.1
  • Removed labels: Milestone-Backlog

@GoogleCodeExporter
Copy link
Author

This feature request seems related:
http://code.google.com/p/nconsoler/issues/detail?id=27

Original comment by [email protected] on 14 Jan 2012 at 5:53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant