File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 1+ using System . IO ;
2+ using System . Diagnostics ;
3+ using ILeoConsole ;
4+ using ILeoConsole . Plugin ;
5+ using ILeoConsole . Core ;
6+
7+ namespace LeoConsole_externalScripts
8+ {
9+ public class ListScripts : ICommand
10+ {
11+ public string Name { get { return "scripts-list" ; } }
12+ public string Description { get { return "list installed scripts" ; } }
13+ public Action CommandFunktion { get { return ( ) => Command ( ) ; } }
14+ private string [ ] _InputProperties ;
15+ public string [ ] InputProperties { get { return _InputProperties ; } set { _InputProperties = value ; } }
16+ public IData data = new ConsoleData ( ) ;
17+
18+ public void Command ( )
19+ {
20+ try {
21+ foreach ( string filename in Directory . GetFiles ( Path . Join ( data . SavePath , "scripts" ) ) ) {
22+ Console . WriteLine ( Path . GetFileName ( filename ) ) ;
23+ }
24+ } catch ( Exception e ) {
25+ Console . WriteLine ( "error: " + e . Message ) ;
26+ }
27+ }
28+ }
29+ }
30+
31+ // vim: tabstop=2 softtabstop=2 shiftwidth=2 expandtab
Original file line number Diff line number Diff line change @@ -33,11 +33,12 @@ public void PluginMain()
3333
3434 _Commands = new List < ICommand > ( ) ;
3535 _Commands . Add ( new Script ( ) ) ;
36+ _Commands . Add ( new ListScripts ( ) ) ;
3637
3738 if ( ! Directory . Exists ( Path . Join ( _data . SavePath , "scripts" ) ) ) {
3839 Console . WriteLine ( "creating scripts directory..." ) ;
3940 try {
40- Directory . CreateDirectory ( Path . Join ( data . SavePath , "scripts" ) ) ;
41+ Directory . CreateDirectory ( Path . Join ( _data . SavePath , "scripts" ) ) ;
4142 } catch ( Exception e ) {
4243 Console . WriteLine ( "WARNING: cannot create scripts dir: " + e . Message ) ;
4344 }
@@ -46,6 +47,4 @@ public void PluginMain()
4647 }
4748}
4849
49- // this tells vim to use 2 spaces instead of tabs, otherwise it's too wide for my taste, but you can adjust it to your needs
50- // if you don' use vim, ignore this, but VIM rules XD
5150// vim: tabstop=2 softtabstop=2 shiftwidth=2 expandtab
You can’t perform that action at this time.
0 commit comments