public int Main(string[] args) { var nonScriptArgs = args.TakeWhile(arg => arg != "--").ToArray(); var scriptArgs = args.Skip(nonScriptArgs.Length + 1).ToArray(); ScriptCsArgs commandArgs; try { commandArgs = ScriptCsArgs.Parse(nonScriptArgs); } catch (Exception ex) { Console.WriteLine(ex.Message); return(1); } if (commandArgs.Config != null && !File.Exists(commandArgs.Config)) { Console.WriteLine("The specified config file does not exist."); return(1); } return(Application.Run(Config.Create(commandArgs), scriptArgs)); }
public static ConfigMask Create(ScriptCsArgs args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } return(new ConfigMask { AllowPreRelease = args.AllowPreRelease ? (bool?)true : null, Cache = args.Cache ? (bool?)true : null, Clean = args.Clean ? (bool?)true : null, Debug = args.Debug ? (bool?)true : null, Global = args.Global ? (bool?)true : null, Install = args.Install, LogLevel = args.LogLevel, Modules = args.Modules, Output = args.Output, PackageVersion = args.PackageVersion, Repl = args.Repl ? (bool?)true : null, Save = args.Save ? (bool?)true : null, ScriptName = args.ScriptName, Watch = args.Watch ? (bool?)true : null, }); }
public static Config Create(ScriptCsArgs commandArgs) { if (commandArgs == null) { throw new ArgumentNullException(nameof(commandArgs)); } return(new Config() .Apply(ConfigMask.ReadGlobalOrDefault()) .Apply(commandArgs.Config == null ? ConfigMask.ReadLocalOrDefault() : ConfigMask.Read(commandArgs.Config)) .Apply(ConfigMask.Create(commandArgs))); }