clispark 1.20.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/cli.js +180 -115
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/templates/dotnet/ARCHITECTURE.md +21 -0
- package/templates/dotnet/README.md +5 -0
- package/templates/node/ARCHITECTURE.md +22 -0
- package/templates/node/README.md +6 -0
- package/templates/node/package.json +3 -1
- package/templates/powershell/ARCHITECTURE.md +8 -0
- package/templates/powershell/Public/Complete-Task.ps1 +10 -0
- package/templates/powershell/Public/Get-Task.ps1 +17 -0
- package/templates/powershell/Public/New-Task.ps1 +17 -0
- package/templates/powershell/README.md +7 -0
- package/templates/powershell/tests/Complete-Task.Tests.ps1 +5 -0
- package/templates/powershell/tests/Get-Task.Tests.ps1 +13 -0
- package/templates/powershell/tests/New-Task.Tests.ps1 +9 -0
package/package.json
CHANGED
|
@@ -94,3 +94,24 @@ There's no separate lint command — analyzer warnings surface as part of a norm
|
|
|
94
94
|
If you answered "no", this `<PropertyGroup>` isn't present, and `dotnet build` runs with only the SDK's own defaults.
|
|
95
95
|
|
|
96
96
|
Either way, this choice is permanent and core-managed: `npx clispark update` keeps this block current for a project that opted in, and will never add it to a project that declined. There's no retroactive "turn lint tooling on later" command — rerun `clispark` in a new directory if you want it.
|
|
97
|
+
|
|
98
|
+
## Shell Completion
|
|
99
|
+
|
|
100
|
+
`System.CommandLine` 2.0.10's `[suggest]` directive is already part of this project's parsing
|
|
101
|
+
pipeline — no code in `Program.cs` or any command needs to change. To activate it in your shell:
|
|
102
|
+
|
|
103
|
+
1. Install the registration tool once per machine: `dotnet tool install -g dotnet-suggest`
|
|
104
|
+
2. Install this project as a global tool (see the README's "Building and running" section), then
|
|
105
|
+
register it once per installation:
|
|
106
|
+
```bash
|
|
107
|
+
dotnet-suggest register --command-path "$(which {{projectName}})"
|
|
108
|
+
```
|
|
109
|
+
(On Windows, use the `.exe` path `dotnet-suggest` prints after `dotnet tool install -g` instead
|
|
110
|
+
of `which`.)
|
|
111
|
+
3. Add shell integration to your profile once per machine:
|
|
112
|
+
```bash
|
|
113
|
+
dotnet-suggest script bash >> ~/.bashrc # or: script powershell, script zsh
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
After that, `{{projectName}} <TAB><TAB>` completes command names automatically — the completion
|
|
117
|
+
logic lives entirely in `dotnet-suggest`/`System.CommandLine`, not in this project's own code.
|
|
@@ -37,6 +37,11 @@ Four example commands ship in `src/Commands/` as copy-paste starting points:
|
|
|
37
37
|
```
|
|
38
38
|
See `ARCHITECTURE.md`'s "Argument Types" section for details.
|
|
39
39
|
|
|
40
|
+
## Shell Completion
|
|
41
|
+
|
|
42
|
+
Tab-completion works out of the box via `System.CommandLine`'s built-in `[suggest]` support — see
|
|
43
|
+
`ARCHITECTURE.md`'s "Shell Completion" section for the one-time `dotnet-suggest` setup.
|
|
44
|
+
|
|
40
45
|
## Logging & debugging
|
|
41
46
|
|
|
42
47
|
Every command run writes a structured log file (one per invocation, in an OS-appropriate log directory — see `ARCHITECTURE.md`'s "Logging" section). By default the terminal only shows a clean `Error: <message>` on failure, or nothing on success.
|
|
@@ -112,3 +112,25 @@ npm run format # prettier --write .
|
|
|
112
112
|
If you answered "no", none of this is present — no config files, no `lint`/`format` scripts, no eslint/prettier devDependencies.
|
|
113
113
|
|
|
114
114
|
Either way, this choice is permanent and core-managed: `npx clispark update` keeps the lint config and its devDependency versions current for a project that opted in, and will never add any of it to a project that declined. There's no retroactive "turn lint tooling on later" command — rerun `clispark` in a new directory if you want it.
|
|
115
|
+
|
|
116
|
+
## Shell Autocompletion
|
|
117
|
+
|
|
118
|
+
If you answered "yes" to "Set up shell autocompletion?" during scaffolding, this project includes
|
|
119
|
+
[`@oclif/plugin-autocomplete`](https://github.com/oclif/plugin-autocomplete) as a runtime
|
|
120
|
+
dependency, registered in `package.json`'s `oclif.plugins` array. Set it up once per shell:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
<cli> autocomplete bash # or zsh, powershell
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
This prints the exact command to append to your shell config (e.g. `~/.bashrc`) and source it.
|
|
127
|
+
After that, `<cli> <TAB><TAB>` completes command names, and `<cli> <command> --<TAB><TAB>`
|
|
128
|
+
completes flag names.
|
|
129
|
+
|
|
130
|
+
If you answered "no", none of this is present — no `@oclif/plugin-autocomplete` dependency, no
|
|
131
|
+
entry in `oclif.plugins`, and the `autocomplete` command itself doesn't exist.
|
|
132
|
+
|
|
133
|
+
Either way, this choice is permanent and core-managed: `npx clispark update` keeps the plugin
|
|
134
|
+
dependency version current for a project that opted in, and will never add it to a project that
|
|
135
|
+
declined. There's no retroactive "turn autocompletion on later" command — rerun `clispark` in a
|
|
136
|
+
new directory if you want it.
|
package/templates/node/README.md
CHANGED
|
@@ -24,6 +24,12 @@ Two example commands ship in `src/commands/` as copy-paste starting points:
|
|
|
24
24
|
```
|
|
25
25
|
See `ARCHITECTURE.md`'s "Argument Types" section for the full set of argument types oclif supports, including a couple this example doesn't use.
|
|
26
26
|
|
|
27
|
+
## Shell Autocompletion
|
|
28
|
+
|
|
29
|
+
If you set up autocompletion during scaffolding, run `node bin/run.ts autocomplete bash` (or
|
|
30
|
+
`zsh`/`powershell`) once to see the exact setup command for your shell. See
|
|
31
|
+
`ARCHITECTURE.md`'s "Shell Autocompletion" section for details.
|
|
32
|
+
|
|
27
33
|
## Logging & debugging
|
|
28
34
|
|
|
29
35
|
Every command run writes a structured JSON log file (one per invocation, in an OS-appropriate log directory — see `ARCHITECTURE.md`'s "Logging" section). By default the terminal only shows a clean `Error: <message>` on failure, or nothing on success.
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"commands": "./dist/commands",
|
|
20
20
|
"topicSeparator": " ",
|
|
21
21
|
"plugins": [
|
|
22
|
-
"@oclif/plugin-help"
|
|
22
|
+
"@oclif/plugin-help",
|
|
23
|
+
"@oclif/plugin-autocomplete"
|
|
23
24
|
]
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@oclif/core": "^4.0.0",
|
|
37
|
+
"@oclif/plugin-autocomplete": "^3.2.53",
|
|
36
38
|
"@oclif/plugin-help": "^6.0.0",
|
|
37
39
|
"env-paths": "^3.0.0",
|
|
38
40
|
"pino": "^9.6.0"
|
|
@@ -24,3 +24,11 @@ exactly. Cmdlet authors never write their own try/catch or logging calls.
|
|
|
24
24
|
## Logging
|
|
25
25
|
|
|
26
26
|
[PSFramework](https://psframework.org/) — see `Logging/Initialize-Logging.ps1`.
|
|
27
|
+
|
|
28
|
+
## Shell Completion
|
|
29
|
+
|
|
30
|
+
Cmdlet-name completion (`Get-H<TAB>` → `Get-Hello`) and parameter-value completion for any
|
|
31
|
+
`[ValidateSet(...)]`-constrained parameter are native PowerShell shell features for every
|
|
32
|
+
imported module — nothing in this project enables them, and nothing could disable them. As soon
|
|
33
|
+
as `Import-Module ./Module.psd1` has run in a session, both kinds of completion work immediately
|
|
34
|
+
for every `Public/` cmdlet.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function Get-Task {
|
|
2
|
+
[CmdletBinding()]
|
|
3
|
+
param(
|
|
4
|
+
[Parameter(Position = 0)]
|
|
5
|
+
[string]$Filter,
|
|
6
|
+
|
|
7
|
+
[switch]$Done
|
|
8
|
+
)
|
|
9
|
+
process {
|
|
10
|
+
$base = if ($Filter) { "Listing tasks matching `"$Filter`"" } else { 'Listing all tasks' }
|
|
11
|
+
if ($Done) {
|
|
12
|
+
Write-Output "$base (completed only: true)"
|
|
13
|
+
} else {
|
|
14
|
+
Write-Output $base
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function New-Task {
|
|
2
|
+
[CmdletBinding()]
|
|
3
|
+
param(
|
|
4
|
+
[Parameter(Mandatory, Position = 0)]
|
|
5
|
+
[string]$Title,
|
|
6
|
+
|
|
7
|
+
[ValidateSet('Low', 'Medium', 'High')]
|
|
8
|
+
[string]$Priority
|
|
9
|
+
)
|
|
10
|
+
process {
|
|
11
|
+
if ($Priority) {
|
|
12
|
+
Write-Output "Created task: `"$Title`" (priority: $Priority)"
|
|
13
|
+
} else {
|
|
14
|
+
Write-Output "Created task: `"$Title`""
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -9,6 +9,13 @@ Import-Module ./Module.psd1
|
|
|
9
9
|
Get-Hello -Name 'World'
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
## Shell Completion
|
|
13
|
+
|
|
14
|
+
Tab-completion works automatically once the module is imported — no setup needed. If you don't
|
|
15
|
+
want to run `Import-Module ./Module.psd1` in every new session, add that line to your PowerShell
|
|
16
|
+
`$PROFILE` (run `$PROFILE` to see its path; `New-Item -Path $PROFILE -ItemType File -Force` first
|
|
17
|
+
if it doesn't exist yet).
|
|
18
|
+
|
|
12
19
|
## Adding a new cmdlet
|
|
13
20
|
|
|
14
21
|
Run `clispark add` from this directory, or drop a new `.ps1` file into `Public/` following the
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Describe 'Get-Task' {
|
|
2
|
+
It 'lists all tasks by default' {
|
|
3
|
+
Get-Task | Should -Be 'Listing all tasks'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
It 'lists tasks matching a filter' {
|
|
7
|
+
Get-Task -Filter 'groceries' | Should -Be 'Listing tasks matching "groceries"'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
It 'lists tasks matching a filter, showing only completed ones' {
|
|
11
|
+
Get-Task -Filter 'groceries' -Done | Should -Be 'Listing tasks matching "groceries" (completed only: true)'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Describe 'New-Task' {
|
|
2
|
+
It 'creates a task with just a title' {
|
|
3
|
+
New-Task -Title 'Buy milk' | Should -Be 'Created task: "Buy milk"'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
It 'creates a task with an optional priority' {
|
|
7
|
+
New-Task -Title 'Buy milk' -Priority 'High' | Should -Be 'Created task: "Buy milk" (priority: High)'
|
|
8
|
+
}
|
|
9
|
+
}
|