@@ -16,26 +16,30 @@ public class InitCommand : ICommand
16
16
public const string COMMAND_ARGUMENTS = "<Path> from ASP.NET Core Project." ;
17
17
public static IList < CommandOption > CommandOptions { get ; set ; } = new List < CommandOption > ( ) ;
18
18
19
- private const string ConfigName = "electron.manifest.json" ;
20
-
21
- private string [ ] _args ;
19
+ private static SimpleCommandLineParser _parser = new SimpleCommandLineParser ( ) ;
20
+ private static string ConfigName = "electron.manifest.json" ;
21
+ private const string DefaultConfigFileName = "electron.manifest.json" ;
22
22
23
23
public InitCommand ( string [ ] args )
24
24
{
25
- _args = args ;
25
+ _parser . Parse ( args ) ;
26
26
}
27
27
28
+ private static string _aspCoreProjectPath = "project-path" ;
29
+ private static string _manifest = "manifest" ;
30
+
28
31
public Task < bool > ExecuteAsync ( )
29
32
{
30
33
return Task . Run ( ( ) =>
31
34
{
32
35
string aspCoreProjectPath = "" ;
33
36
34
- if ( _args . Length > 0 )
37
+ if ( _parser . Arguments . ContainsKey ( _aspCoreProjectPath ) )
35
38
{
36
- if ( Directory . Exists ( _args [ 0 ] ) )
39
+ string projectPath = _parser . Arguments [ _aspCoreProjectPath ] . First ( ) ;
40
+ if ( Directory . Exists ( projectPath ) )
37
41
{
38
- aspCoreProjectPath = _args [ 0 ] ;
42
+ aspCoreProjectPath = projectPath ;
39
43
}
40
44
}
41
45
else
@@ -45,7 +49,15 @@ public Task<bool> ExecuteAsync()
45
49
46
50
var currentDirectory = aspCoreProjectPath ;
47
51
48
- Console . WriteLine ( "Adding our config file to your project..." ) ;
52
+ if ( _parser . Arguments . ContainsKey ( _manifest ) )
53
+ {
54
+ ConfigName = "electron.manifest." + _parser . Arguments [ _manifest ] . First ( ) + ".json" ;
55
+ Console . WriteLine ( $ "Adding your custom { ConfigName } config file to your project...") ;
56
+ }
57
+ else
58
+ {
59
+ Console . WriteLine ( "Adding our config file to your project..." ) ;
60
+ }
49
61
50
62
var targetFilePath = Path . Combine ( currentDirectory , ConfigName ) ;
51
63
@@ -56,7 +68,7 @@ public Task<bool> ExecuteAsync()
56
68
}
57
69
58
70
// Deploy config file
59
- EmbeddedFileHelper . DeployEmbeddedFile ( currentDirectory , ConfigName ) ;
71
+ EmbeddedFileHelper . DeployEmbeddedFileToTargetFile ( currentDirectory , DefaultConfigFileName , ConfigName ) ;
60
72
61
73
// search .csproj
62
74
Console . WriteLine ( $ "Search your .csproj to add the needed { ConfigName } ...") ;
@@ -99,7 +111,32 @@ private static void EditLaunchSettings(string currentDirectory)
99
111
100
112
string launchSettingText = File . ReadAllText ( launchSettingFile ) ;
101
113
102
- if ( launchSettingText . Contains ( "\" executablePath\" : \" electronize\" " ) == false )
114
+ if ( _parser . Arguments . ContainsKey ( _manifest ) )
115
+ {
116
+ string manifestName = _parser . Arguments [ _manifest ] . First ( ) ;
117
+
118
+ if ( launchSettingText . Contains ( "start /manifest " + ConfigName ) == false )
119
+ {
120
+ StringBuilder debugProfileBuilder = new StringBuilder ( ) ;
121
+ debugProfileBuilder . AppendLine ( "profiles\" : {" ) ;
122
+ debugProfileBuilder . AppendLine ( " \" Electron.NET App - " + manifestName + "\" : {" ) ;
123
+ debugProfileBuilder . AppendLine ( " \" commandName\" : \" Executable\" ," ) ;
124
+ debugProfileBuilder . AppendLine ( " \" executablePath\" : \" electronize\" ," ) ;
125
+ debugProfileBuilder . AppendLine ( " \" commandLineArgs\" : \" start /manifest " + ConfigName + "\" ," ) ;
126
+ debugProfileBuilder . AppendLine ( " \" workingDirectory\" : \" .\" " ) ;
127
+ debugProfileBuilder . AppendLine ( " }," ) ;
128
+
129
+ launchSettingText = launchSettingText . Replace ( "profiles\" : {" , debugProfileBuilder . ToString ( ) ) ;
130
+ File . WriteAllText ( launchSettingFile , launchSettingText ) ;
131
+
132
+ Console . WriteLine ( $ "Debug profile added!") ;
133
+ }
134
+ else
135
+ {
136
+ Console . WriteLine ( $ "Debug profile already existing") ;
137
+ }
138
+ }
139
+ else if ( launchSettingText . Contains ( "\" executablePath\" : \" electronize\" " ) == false )
103
140
{
104
141
StringBuilder debugProfileBuilder = new StringBuilder ( ) ;
105
142
debugProfileBuilder . AppendLine ( "profiles\" : {" ) ;
0 commit comments