public void TestArgWithSingleQuotes() { string arg = "'quotes'"; string escaped = "\\'quotes\\'"; Assert.AreEqual(escaped, CStringUtils.Arg(arg)); Assert.AreEqual(arg, CStringUtils.UnArg(escaped)); }
public void TestArgWithQuotesAndSpaces() { string arg = "spaces and \"quotes\""; string escaped = "\"spaces and \\\"quotes\\\"\""; Assert.AreEqual(escaped, CStringUtils.Arg(arg)); Assert.AreEqual(arg, CStringUtils.UnArg(escaped)); }
public void TestArgWithSpaceAndSingleQuotes() { string arg = "some 'arg with' spaces"; string escaped = "\"some \\'arg with\\' spaces\""; Assert.AreEqual(escaped, CStringUtils.Arg(arg)); Assert.AreEqual(arg, CStringUtils.UnArg(escaped)); }
public void TestArgWithNoSpace() { string arg = "arg"; string escaped = arg; Assert.AreEqual(escaped, CStringUtils.Arg(arg)); Assert.AreEqual(arg, CStringUtils.UnArg(escaped)); }
public void TestArgWithSpace() { string arg = "some arg with spaces"; string escaped = '"' + arg + '"'; Assert.AreEqual(escaped, CStringUtils.Arg(arg)); Assert.AreEqual(arg, CStringUtils.UnArg(escaped)); }
void Execute(string prefix = null) { IList <CBinding> bindings = CBindings.List(prefix); foreach (CBinding b in bindings) { PrintIndent("bind {0} {1}", b.shortCut.ToString(), CStringUtils.Arg(b.cmdKeyDown)); } }
private string GetOptionsUsage(List <Option> options) { if (options != null && options.Count > 0) { StringBuilder buffer = new StringBuilder(); for (int i = 0; i < options.Count; ++i) { Option opt = options[i]; buffer.Append(' '); if (!opt.IsRequired) { buffer.Append('['); } if (opt.ShortName != null) { buffer.AppendFormat("-{0}|", CStringUtils.C(opt.ShortName, CColorCode.TableVar)); } buffer.AppendFormat("--{0}", CStringUtils.C(opt.Name, CColorCode.TableVar)); if (opt.Type != typeof(bool)) { if (opt.HasValues()) { string[] values = opt.Values; buffer.Append(" <"); for (int valueIndex = 0; valueIndex < values.Length; ++valueIndex) { buffer.Append(CStringUtils.Arg(values[valueIndex])); if (valueIndex < values.Length - 1) { buffer.Append("|"); } } buffer.Append('>'); } else { buffer.AppendFormat(" <{0}>", UsageOptionName(opt)); } } if (!opt.IsRequired) { buffer.Append(']'); } } return(buffer.ToString()); } return(null); }
public static string CreateCommandLine(string[] args, int startIndex = 0) { StringBuilder buffer = new StringBuilder(); for (int i = startIndex; i < args.Length; ++i) { buffer.Append(CStringUtils.Arg(args[i])); if (i < args.Length - 1) { buffer.Append(' '); } } return(buffer.ToString()); }
private static IList <string> ListCvars() { IList <CVar> cvars = CRegistery.ListVars(delegate(CVarCommand cmd) { return(!cmd.IsDefault && !cmd.HasFlag(CFlags.NoArchive)); }); IList <string> entries = new List <string>(cvars.Count); foreach (CVar cvar in cvars) { if (cvar.Value != null) { entries.Add(string.Format("{0} {1}", cvar.Name, CStringUtils.Arg(cvar.Value))); } else { entries.Add("null " + cvar.Name); } } return(entries); }
internal static string Arg(string value) { return(CStringUtils.Arg(value)); }
bool Execute(string prefix = null) { CCommandListOptions options = CCommand.DefaultListOptions; if (includeSystem) { options |= CCommandListOptions.System; } // TODO: refactoring IList <CVar> vars = CRegistery.ListVars(prefix, options); if (vars.Count > 0) { if (shortList) { string[] names = CCollection.Map(vars, delegate(CVar cvar) { return(CStringUtils.C(cvar.Name, CColorCode.TableVar)); }); Print(names); } else { StringBuilder result = new StringBuilder(); for (int i = 0; i < vars.Count; ++i) { CVar cvar = vars[i]; result.AppendFormat(" {0} {1}", CStringUtils.C(cvar.Name, CColorCode.TableVar), CStringUtils.Arg(cvar.Value)); // TODO: better color highlight if (!cvar.IsDefault) { result.AppendFormat(" {0} {1}", CStringUtils.C("default", CColorCode.TableVar), cvar.DefaultValue); } if (i < vars.Count - 1) { result.Append('\n'); } } Print(result.ToString()); } } return(true); }
private static IList <string> ListBindings() { IList <CBinding> bindings = CBindings.List(); IList <string> entries = new List <string>(bindings.Count); foreach (CBinding binding in bindings) { entries.Add(string.Format("bind {0} {1}", binding.shortCut.ToString(), CStringUtils.Arg(binding.cmdKeyDown))); } return(entries); }
private static string ToString(CAliasCommand cmd) { return(string.Format("alias {0} {1}", cmd.Name, CStringUtils.Arg(cmd.Alias))); }
public static string ToString(CBinding b) { return(string.Format("bind {0} {1}", b.shortCut.ToString(), CStringUtils.Arg(b.cmdKeyDown))); }