commandline icon indicating copy to clipboard operation
commandline copied to clipboard

Add UseDoubleQuoteOnArguments to UnParserSettings

Open lukefan6 opened this issue 9 years ago • 3 comments

Consider following scenario:

	public class ScaffoldCommand
	{
		[Value(0)]
		public string ConnectionString { get; set; }
                [Value(1)]
		public string Provider { get; set; }
        }

ConnectionString could be a long string that contains spaces and we usually surround them with double quotes so the CLI could recognize it, take entity framework core for example:

dotnet ef dbcontext scaffold "Data Source = xxxxxx;Database = xxxxxx; User ID=xxxxxx; Password=xxxxxx" Microsoft.EntityFrameworkCore.SqlServer

Currently public static string FormatCommandLine<T>(this Parser parser, T options, Action<UnParserSettings> configuration); does not seem to have this kind of capability, I can only generate arguments without double quotes.

I wonder if we could add something like UseDoubleQuoteOnArguments to UnParserSettings so we could configure it to generate arguments surrounded by double quotes.

Any thoughts?

lukefan6 avatar Nov 07 '16 15:11 lukefan6

IMO that should be a default feature . Can you think of a reason why anyone would want to turn it off, assuming quotes are only added if there is whitespace in the value?

nemec avatar Nov 09 '16 18:11 nemec

Actually adding quotes only when there is whitespace would be better. I was not thinking straight lol.

lukefan6 avatar Nov 10 '16 02:11 lukefan6

I desperately wanted this feature 1-2 years ago, and for the same reason: it was much more convenient to supply values such as connection strings by wrapping them in double-quotes. It would be great to see CLP support passing values in this way.

ghost avatar Feb 02 '17 17:02 ghost