11using System ;
2- using System . IO ;
3- using Newtonsoft . Json ;
4- using Newtonsoft . Json . Converters ;
52using ScriptCs . Contracts ;
3+ using System . IO ;
64
75namespace ScriptCs
86{
9- // NOTE (Adam): passed across app domains as a property of CrossAppDomainExecuteScriptCommand
7+ // NOTE (Adam): passed across app domains as a property of CrossAppDomainExecuteScriptCommand
108 [ Serializable ]
119 public class Config
1210 {
@@ -15,34 +13,38 @@ public Config()
1513 LogLevel = LogLevel . Info ;
1614 }
1715
18- public bool Repl { get ; set ; }
16+ // global
17+ public LogLevel LogLevel { get ; set ; }
1918
20- public string ScriptName { get ; set ; }
19+ public string Modules { get ; set ; }
2120
22- public bool Debug { get ; set ; }
21+ public string Output { get ; set ; }
2322
24- public bool Cache { get ; set ; }
23+ // clean command
24+ public bool Clean { get ; set ; }
2525
26- [ JsonConverter ( typeof ( StringEnumConverter ) ) ]
27- public LogLevel LogLevel { get ; set ; }
26+ // install command
27+ public bool AllowPreRelease { get ; set ; }
28+
29+ public bool Global { get ; set ; }
2830
2931 public string Install { get ; set ; }
3032
31- public bool Global { get ; set ; }
33+ public string PackageVersion { get ; set ; }
3234
35+ // save command
3336 public bool Save { get ; set ; }
3437
35- public bool Clean { get ; set ; }
36-
37- public bool AllowPreRelease { get ; set ; }
38+ // run command
39+ public string ScriptName { get ; set ; }
3840
39- public bool Watch { get ; set ; }
41+ public bool Cache { get ; set ; }
4042
41- public string Modules { get ; set ; }
43+ public bool Debug { get ; set ; }
4244
43- public string PackageVersion { get ; set ; }
45+ public bool Repl { get ; set ; }
4446
45- public string Output { get ; set ; }
47+ public bool Watch { get ; set ; }
4648
4749 public Config Apply ( ConfigMask mask )
4850 {
@@ -51,27 +53,29 @@ public Config Apply(ConfigMask mask)
5153 return this ;
5254 }
5355
54- var scriptName = mask . ScriptName ?? ScriptName ;
55- if ( scriptName != null && ! Path . HasExtension ( scriptName ) )
56- {
57- scriptName += ".csx" ;
58- }
56+ var logLevel = mask . Debug . GetValueOrDefault ( ) && ! mask . LogLevel . HasValue && LogLevel != LogLevel . Trace
57+ ? LogLevel . Debug
58+ : mask . LogLevel ;
59+
60+ var scriptName = mask . ScriptName != null && ! Path . GetFileName ( mask . ScriptName ) . Contains ( "." )
61+ ? Path . ChangeExtension ( mask . ScriptName , "csx" )
62+ : mask . ScriptName ;
5963
6064 return new Config
6165 {
62- AllowPreRelease = mask . AllowPreRelease ?? AllowPreRelease ,
63- Cache = mask . Cache ?? Cache ,
66+ LogLevel = logLevel ?? LogLevel ,
67+ Modules = mask . Modules ?? Modules ,
68+ Output = mask . Output ?? Output ,
6469 Clean = mask . Clean ?? Clean ,
65- Debug = mask . Debug ?? Debug ,
70+ AllowPreRelease = mask . AllowPreRelease ?? AllowPreRelease ,
6671 Global = mask . Global ?? Global ,
6772 Install = mask . Install ?? Install ,
68- LogLevel = mask . Debug . HasValue && mask . Debug . Value ? LogLevel . Debug : mask . LogLevel ?? LogLevel ,
69- Modules = mask . Modules ?? Modules ,
70- Output = mask . Output ?? Output ,
7173 PackageVersion = mask . PackageVersion ?? PackageVersion ,
72- Repl = mask . Repl ?? Repl ,
7374 Save = mask . Save ?? Save ,
74- ScriptName = scriptName ,
75+ Cache = mask . Cache ?? Cache ,
76+ Debug = mask . Debug ?? Debug ,
77+ Repl = mask . Repl ?? Repl ,
78+ ScriptName = scriptName ?? ScriptName ,
7579 Watch = mask . Watch ?? Watch ,
7680 } ;
7781 }
0 commit comments