codeformatter icon indicating copy to clipboard operation
codeformatter copied to clipboard

Passing /nocopyright from bash command line returns an error.

Open marcelodeaguiar opened this issue 10 years ago • 16 comments

Passing /nocopyright from a bash command line (like git bash) returns the error: Error: The specified rule type was not find: path-to-file/nocopyright

I think it has something to do with the StringComparer.OrdinalIgnoreCase used to parse the arguments.

marcelodeaguiar avatar Feb 10 '15 18:02 marcelodeaguiar

I just used this switch today on some code I was working on and it functioned as expected. Could you show me the exact command line you were using?

jaredpar avatar Feb 15 '15 18:02 jaredpar

Sure,

error

I made some tests and it has nothing to do with the comparer, but with the way git bash interprets my commands. the argument is passed as C:/Program Files (x86)/Git/nocopyright intead of /nocopyright problably because of the /.

Changing the params to start with dash (-) or double dashes (--) works fine.

My environment: Win 10 Tech Preview VS 2015 Git/Bash 1.9.5

marcelodeaguiar avatar Feb 16 '15 11:02 marcelodeaguiar

Isn't this a shell problem rather than a bug in the formatter?

khellang avatar Feb 16 '15 12:02 khellang

@khellang I don't know if its bug. Isn't it the way unix based shells work? Git bash is a fairly common shell so I think it should be considered...

marcelodeaguiar avatar Feb 16 '15 12:02 marcelodeaguiar

Well, you might argue that / isn't the best way to denote a switch/flag cross-plat. I guess that's why most UNIX stuff use - or -- :smile:

I'm not sure there's a way around it other than switching the character, since Git Bash ends up passing a path. Maybe do the check using .EndsWith? :stuck_out_tongue_closed_eyes:

khellang avatar Feb 16 '15 13:02 khellang

@khellang I think the best approach is to use -- as its pretty common and its an easy solution. .EndsWith looks more like a bad workaround I think.

I can submit the change if it is accepted.

marcelodeaguiar avatar Feb 16 '15 13:02 marcelodeaguiar

Maybe something like Mono.Options or similar could be used?

khellang avatar Feb 16 '15 14:02 khellang

I think we need to move to accept - as an option specifier.

jaredpar avatar Feb 16 '15 14:02 jaredpar

@jaredpar - I suspect that's right. After using git all the time, the dashes are starting to feel quite natural.

richlander avatar Feb 16 '15 15:02 richlander

Most of the tools use 2 dashes for option full name and 1 dash for option shortcut. You can see this all over Git documentation, Eg: --force and -f or --directory and -d

@khellang I did not know Mono.Options but it looks awesome.

marcelodeaguiar avatar Feb 16 '15 17:02 marcelodeaguiar

@marcelodeaguiar Yep, it's a quick way to get decent command line options (supporting -, -- and / switches) with minimal fuzz (I think its just a single .cs file). :smile:

khellang avatar Feb 16 '15 20:02 khellang

It seems that more detail in the error message would be helpful.

GaTechThomas avatar Feb 28 '15 18:02 GaTechThomas

@GaTechThomas what extra data could help here?

jaredpar avatar Mar 02 '15 15:03 jaredpar

I don't use unix, so I can't reproduce, but from the screenshot it looks like the error output is a bit confusing. Maybe showing something along the lines of "Executing Codeformatter.exe using the following parameters: ...".

That output may not be desirable for all runs, but maybe so when the -verbose option is set.

GaTechThomas avatar Mar 02 '15 18:03 GaTechThomas

@GaTechThomas but what makes CodeFormatter special here? Why shouldn't all console apps have this output?

jaredpar avatar Mar 02 '15 18:03 jaredpar

I would expect that any app writing verbose output would be better served by displaying this sort of information.

It's the equivalent of, say, asking a contractor to do a series of things around the house, and then having them repeat back in detail what they're going to do... Sometimes things get lost in how they are asked or how they're heard, or both, and both parties are better off for having clarified the scope of work.

GaTechThomas avatar Mar 03 '15 13:03 GaTechThomas