Discusion for fixing Work Item 1554

Sep 29, 2011 at 4:55 AM
Edited Sep 29, 2011 at 6:27 AM


#1. Question

I found the code like that below in CommandLine project. Why do we need to use StartsWith()? if user type "pa" then it will still go to "pack", isn't it? Would it be the problem when we have similar command name?

  var results = from prop in properties
                              where prop.Value.Name.StartsWith(optionText, StringComparison.OrdinalIgnoreCase) ||
                              (prop.Key.AltName ?? String.Empty).StartsWith(optionText, StringComparison.OrdinalIgnoreCase)
                              select prop;

 IEnumerable<ICommand> results = from cmd in _commands
                                            where cmd.CommandAttribute.CommandName.StartsWith(commandName, StringComparison.OrdinalIgnoreCase) ||
                                            (cmd.CommandAttribute.AltName ?? String.Empty).StartsWith(commandName, StringComparison.OrdinalIgnoreCase)
                                            select cmd;

#2. Suggestion
We have the following code in "ICommand ExtractOptions(ICommand command, IEnumerator<string> argsEnumerator)" of CommandLineParser.
if (propInfo.PropertyType == typeof(bool)) {
                    value = value ?? "true";
                else {
                    value = GetNextCommandLineItem(argsEnumerator);

What about if we make a special treat for "OutputDirectory" of PackCommand and loop thru the next command line item to get the full path until we found the next option. What do you think?

#3. Question

Why do we use command.Arguments.AddRange(arguments); for reading "input file"?

I found that argument are added and use only in GetInputFile() of PackCommand class. But of course, it use "Sync\Fork" which is invalid.

Let's say the path of -o is "C:\Michael Sync\Fork".. then. -o = "C:\Michael" and argument[0] = "Sync\Fork".

Sep 30, 2011 at 2:56 AM

Hi Guys,

If you have any questions or my post is not clear enough then please feel free to let me know.. 

Oct 12, 2011 at 5:43 PM

1) Right, we allow powershell \ mercurial style short names for commands and arguments. If there's a conflict, we print out the ambiguities.

PS D:\forks\nuget> nuget p
Ambiguous command 'p'. Possible values: publish pack push.

2) I didn't realize we were not doing this. We should be able to read everything inside a pair of double quotes as a single value, we shouldn't have to special case OutputPath.

3) Typically Argument would map to the "default" property so you could do nuget.exe install Foo without having to specify a parameter for Foo. Is that what you meant by the 3rd question?