You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Docs/Design_command.md
+18-1Lines changed: 18 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,24 @@ public class ConvertCommand : CommandBase<PowerCommandsConfiguration>
94
94
}
95
95
}
96
96
```
97
-
### **Please Note** that the name of the arguments in the design attribute is not important in code, it is useful thou when help about the command is displayed. Suggestions is what it sounds like only suggestions to guide the user to the right input.
97
+
**Please Note** that the name of the arguments in the design attribute is not important in code, it is useful thou when help about the command is displayed. Suggestions is what it sounds like only suggestions to guide the user to the right input.
98
+
99
+
### Inherit CdCommand to add file/dir code completion
100
+
If you are design a command that will handle files or directories you may want to help the user with code completion, you can implement this easily just inherit the CdCommand and then your Command will support just that!
101
+
The Command below wil handle navigation trough files and directories (in current working folder) just using tab. PowerCommand has `cd` command and `dir` commands out of the box.
102
+
```
103
+
[PowerCommandDesign(description: "Run commands that supports pipe functionality.",
104
+
example: "//First run this command and then the version command|version [PIPE] pipe")]
105
+
public class BrowseCommand(string identifier, PowerCommandsConfiguration configuration) : CdCommand(identifier, configuration)
106
+
{
107
+
public override RunResult Run()
108
+
{
109
+
var fileName = Input.SingleArgument;
110
+
WriteLine(fileName);
111
+
return Ok();;
112
+
}
113
+
}
114
+
```
98
115
99
116
## Must I use the PowerCommandDesign attribute on every command I create?
100
117
No that is not mandatory but it is recommended, note that when you declare the [Options](Options.md), they will be available for code completion, which means that when the consumer types - and hit the tab button the user will can se what options there are that could be used, with a simple ! character you tell that the argument, quote, option or secret is required and then the Core runtime will validate that automatically for you.
Add a filter and show only the content in current working directory that matches the filter
51
-
52
-
```dir --filter .txt```
53
-
54
-
Show the content in current working directory and browse the directory in the file browser.
55
-
56
-
```dir --browse```
57
-
58
-
Show info about the available drives on your system
59
-
60
-
```dir --drive-info```
61
-
62
-
Dir also have som nice features that also CdCommand has, as it inherits that command, but that is undocumented as it is unintentional features.
63
-
You could for example change the current working directory by writing ```dir directory-name```
64
-
65
43
## CdCommand
66
44
67
45
You use the cd command pretty much as you would use it in a standard Windows console.
@@ -86,6 +64,46 @@ Change directory to a special directory using a option flag, the special directo
86
64
87
65
This will change working directory to the application roaming directory for PowerCommands.
88
66
67
+
### Inherit CdCommand to add file/dir code completion
68
+
If you are design a command that will handle files or directories you may want to help the user with code completion, you can implement this easily just inherit the CdCommand and then your Command will support just that!
69
+
The Command below wil handle navigation trough files and directories (in current working folder) just using tab.
70
+
```
71
+
[PowerCommandDesign(description: "Run commands that supports pipe functionality.",
72
+
example: "//First run this command and then the version command|version [PIPE] pipe")]
73
+
public class BrowseCommand(string identifier, PowerCommandsConfiguration configuration) : CdCommand(identifier, configuration)
0 commit comments