forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptCsArgs.cs
More file actions
69 lines (55 loc) · 2.5 KB
/
ScriptCsArgs.cs
File metadata and controls
69 lines (55 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Linq;
using PowerArgs;
namespace ScriptCs
{
[ArgExample("scriptcs server.csx -debug", "Shows how to start the script with debug mode switched on")]
public class ScriptCsArgs
{
[ArgIgnore]
public bool Repl { get; set; }
[ArgPosition(0)]
[ArgDescription("Script file name, must be specified first")]
public string ScriptName { get; set; }
[ArgDescription("Displays help")]
[ArgShortcut("?")]
public bool Help { get; set; }
[ArgShortcut("debug")]
[ArgDescription("Flag which switches on debug mode")]
public bool Debug { get; set; }
[ArgIgnoreCase]
[ArgShortcut("log")]
[DefaultValue(LogLevel.Info)]
[ArgDescription("Flag which defines the log level used.")]
public LogLevel LogLevel { get; set; }
[ArgShortcut("install")]
[ArgDescription("Installs and restores packages which are specified in packages.config")]
public string Install { get; set; }
[ArgShortcut("restore")]
[ArgDescription("Restores installed packages, making them ready for using by the script")]
public bool Restore { get; set; }
[ArgShortcut("save")]
[ArgDescription("Creates a packages.config file based on the packages directory")]
public bool Save { get; set; }
[ArgShortcut("clean")]
[ArgDescription("Cleans installed packages from working directory")]
public bool Clean { get; set; }
[ArgShortcut("pre")]
[ArgDescription("Allows installation of packages' prelease versions")]
public bool AllowPreRelease { get; set; }
[ArgShortcut("version")]
[ArgDescription("Outputs version information")]
public bool Version { get; set; }
public static void SplitScriptArgs(ref string[] args, out string[] scriptArgs)
{
// Split the arguments list on "--".
// The arguments before the "--" (or all arguments if there is no "--") are
// for ScriptCs.exe, and the arguments after that are for the csx script.
int separatorLocation = Array.IndexOf(args, "--");
int scriptArgsCount = separatorLocation == -1 ? 0 : args.Length - separatorLocation - 1;
scriptArgs = new string[scriptArgsCount];
Array.Copy(args, separatorLocation + 1, scriptArgs, 0, scriptArgsCount);
if (separatorLocation != -1) args = args.Take(separatorLocation).ToArray();
}
}
}