codeformatter
codeformatter copied to clipboard
Passing /nocopyright from bash command line returns an error.
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.
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?
Sure,
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
Isn't this a shell problem rather than a bug in the formatter?
@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...
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
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.
Maybe something like Mono.Options or similar could be used?
I think we need to move to accept -
as an option specifier.
@jaredpar - I suspect that's right. After using git all the time, the dashes are starting to feel quite natural.
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 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:
It seems that more detail in the error message would be helpful.
@GaTechThomas what extra data could help here?
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 but what makes CodeFormatter special here? Why shouldn't all console apps have this output?
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.