66
77namespace LeoConsole_externalScripts {
88 public class Script : ICommand {
9- public string Name { get { return "script" ; } }
10- public string Description { get { return "run script" ; } }
9+ public string Name { get ; set ; }
10+ public string Description { get { return "external script" ; } }
1111 public Action CommandFunktion { get { return ( ) => Command ( ) ; } }
1212 private string [ ] _InputProperties ;
1313 public string [ ] InputProperties { get { return _InputProperties ; } set { _InputProperties = value ; } }
1414 public IData data = new ConsoleData ( ) ;
1515
16+ public Script ( string name ) {
17+ Name = name ;
18+ }
19+
1620 public void Command ( ) {
17- if ( _InputProperties . Length < 2 ) {
18- Console . WriteLine ( "you need to provide the script name to run" ) ;
19- return ;
21+ string username = data . User . name . Replace ( " " , "-" ) ;
22+ if ( username == "" ) {
23+ username = "-" ;
24+ }
25+ string savepath = data . SavePath . Replace ( " " , "-" ) ;
26+ if ( savepath == "" ) {
27+ savepath = "-" ;
28+ }
29+ string dlpath = data . DownloadPath . Replace ( " " , "-" ) ;
30+ if ( dlpath == "" ) {
31+ dlpath = "-" ;
2032 }
21- Console . WriteLine ( "running " + _InputProperties [ 1 ] + "..." ) ;
2233 string args = "" ;
2334 for ( int i = 1 ; i < _InputProperties . Length ; i ++ ) {
2435 args = args + " " + _InputProperties [ i ] ;
2536 }
2637
2738 if ( ! runProcess (
28- Path . Join ( data . SavePath , "share" , "scripts" , _InputProperties [ 1 ] ) ,
29- $ "{ data . User . name } { data . SavePath } { data . DownloadPath } { args } ",
30- data . SavePath )
31- ) {
32- Console . WriteLine ( "error running " + _InputProperties [ 1 ] ) ;
39+ Path . Join ( data . SavePath , "share" , "scripts" , Name ) ,
40+ $ "{ username } { savepath } { dlpath } { args } ",
41+ data . SavePath
42+ ) ) {
43+ Console . WriteLine ( "error running " + Name ) ;
3344 }
3445 }
3546
@@ -52,7 +63,6 @@ private bool runProcess(string name, string args, string pwd) {
5263 }
5364 return true ;
5465 }
55-
5666 }
5767}
5868
0 commit comments