File tree Expand file tree Collapse file tree 3 files changed +66
-1
lines changed Expand file tree Collapse file tree 3 files changed +66
-1
lines changed Original file line number Diff line number Diff line change
1
+ using System . IO ;
2
+ using System . Net ;
3
+ using ILeoConsole ;
4
+ using ILeoConsole . Plugin ;
5
+ using ILeoConsole . Core ;
6
+
7
+ namespace LeoConsole_ExamplePlugin {
8
+ public class Hostname : ICommand {
9
+ public string Name { get { return "hostname" ; } }
10
+ public string Description { get { return "print computer's hostname" ; } }
11
+ public Action CommandFunktion { get { return ( ) => Command ( ) ; } }
12
+ private string [ ] _InputProperties ;
13
+ public string [ ] InputProperties { get { return _InputProperties ; } set { _InputProperties = value ; } }
14
+
15
+ public void Command ( ) {
16
+ Console . WriteLine ( Dns . GetHostName ( ) ) ;
17
+ }
18
+ }
19
+ }
20
+
21
+ // vim: tabstop=2 softtabstop=2 shiftwidth=2 expandtab
Original file line number Diff line number Diff line change
1
+ using System . IO ;
2
+ using ILeoConsole ;
3
+ using ILeoConsole . Plugin ;
4
+ using ILeoConsole . Core ;
5
+
6
+ namespace LeoConsole_ExamplePlugin {
7
+ public class Ls : ICommand {
8
+ public string Name { get { return "ls" ; } }
9
+ public string Description { get { return "list contents of a folder" ; } }
10
+ public Action CommandFunktion { get { return ( ) => Command ( ) ; } }
11
+ private string [ ] _InputProperties ;
12
+ public string [ ] InputProperties { get { return _InputProperties ; } set { _InputProperties = value ; } }
13
+ public IData data = new ConsoleData ( ) ;
14
+
15
+ public void Command ( ) {
16
+ if ( _InputProperties . Length < 2 ) {
17
+ ls ( data . SavePath ) ;
18
+ return ;
19
+ }
20
+ for ( int i = 1 ; i < _InputProperties . Length ; i ++ ) {
21
+ ls ( _InputProperties [ i ] ) ;
22
+ Console . Write ( "\n " ) ;
23
+ }
24
+ }
25
+
26
+ private void ls ( string directory ) {
27
+ Console . WriteLine ( directory + ":" ) ;
28
+ try {
29
+ foreach ( string filename in Directory . GetDirectories ( directory ) ) {
30
+ Console . WriteLine ( Path . GetFileName ( filename ) + "/" ) ;
31
+ }
32
+ foreach ( string filename in Directory . GetFiles ( directory ) ) {
33
+ Console . WriteLine ( Path . GetFileName ( filename ) ) ;
34
+ }
35
+ } catch ( Exception e ) {
36
+ Console . WriteLine ( "error: " + e . Message ) ;
37
+ }
38
+ }
39
+ }
40
+ }
41
+
42
+ // vim: tabstop=2 softtabstop=2 shiftwidth=2 expandtab
Original file line number Diff line number Diff line change @@ -29,10 +29,12 @@ public void PluginMain() {
29
29
30
30
_Commands = new List < ICommand > ( ) ;
31
31
_Commands . Add ( new Basename ( ) ) ;
32
+ _Commands . Add ( new Cat ( ) ) ;
32
33
_Commands . Add ( new Clear ( ) ) ;
33
34
_Commands . Add ( new Echo ( ) ) ;
35
+ _Commands . Add ( new Hostname ( ) ) ;
36
+ _Commands . Add ( new Ls ( ) ) ;
34
37
_Commands . Add ( new Yes ( ) ) ;
35
- _Commands . Add ( new Cat ( ) ) ;
36
38
}
37
39
}
38
40
}
You can’t perform that action at this time.
0 commit comments