Skip to content

Commit 5b0ac9e

Browse files
committed
Updated the documentation.
1 parent f905e21 commit 5b0ac9e

File tree

2 files changed

+58
-23
lines changed

2 files changed

+58
-23
lines changed

Docs/Design_command.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,24 @@ public class ConvertCommand : CommandBase<PowerCommandsConfiguration>
9494
}
9595
}
9696
```
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+
```
98115

99116
## Must I use the PowerCommandDesign attribute on every command I create?
100117
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.

Docs/ReadWriteFileHandler.md

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,6 @@ This will also work.
4040

4141
```version version.txt | file```
4242

43-
## DirCommand
44-
![Alt text](images/dir_and_file_command.png?raw=true "Dir commands")
45-
46-
Show the content in current working directory
47-
48-
```dir```
49-
50-
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-
6543
## CdCommand
6644

6745
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
8664

8765
This will change working directory to the application roaming directory for PowerCommands.
8866

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)
74+
{
75+
public override RunResult Run()
76+
{
77+
var fileName = Input.SingleArgument;
78+
WriteLine(fileName);
79+
return Ok();;
80+
}
81+
}
82+
```
83+
84+
85+
## DirCommand
86+
![Alt text](images/dir_and_file_command.png?raw=true "Dir commands")
87+
88+
Show the content in current working directory
89+
90+
```dir```
91+
92+
Add a filter and show only the content in current working directory that matches the filter
93+
94+
```dir --filter .txt```
95+
96+
Show the content in current working directory and browse the directory in the file browser.
97+
98+
```dir --browse```
99+
100+
Show info about the available drives on your system
101+
102+
```dir --drive-info```
103+
104+
Dir also have som nice features that also CdCommand has, as it inherits that command, but that is undocumented as it is unintentional features.
105+
You could for example change the current working directory by writing ```dir directory-name```
106+
89107
Read more about:
90108

91109
[Configuration (see example on how you can add your bookmarks)](Configuration.md)

0 commit comments

Comments
 (0)