Repository navigation
Commit a0805a0
skills read: end flags before a leading-hyphen file name (#8121)
`databricks skills read` prints a `databricks skills read-file <name>
<path>` command for each supporting file. A name or path that starts
with `-` was read by Cobra as a flag when an agent ran the printed
command, so the file could not be read. This PR prints `--` before the
arguments in that case.
## Changes
- `skills read` prints `databricks skills read-file -- <name> <path>`
when the skill name or the file path starts with `-`.
- Other names print exactly as before, so existing output is unchanged.
- `read-file` needs no change: Cobra already treats the arguments after
`--` as positional.
## Why
A file such as `-notes.md` is listed in the manifest and the manifest
checks accept it, but the printed command `read-file guide-skill
-notes.md` fails with an unknown flag. Ending the flags with `--` lets
the printed command read the file as printed.
## Decisions to review
- `--` is printed only when a name or path starts with `-`, not always.
Always printing it would change the output for every skill, and the
existing goldens with it. The cost is one extra branch in
`writeReadText`.
## Tests
- `TestWriteReadTextEndsFlagsBeforeLeadingHyphenFile` covers a
leading-hyphen file name, a leading-hyphen skill name, and a
leading-hyphen file name that also needs quotes (Linux and Windows
quoting), and checks that ordinary files on the same line keep their
command.
- `acceptance/cmd/skills/read` checks that the printed command for
`-notes.md` (a file in the shared release fixture) appears in the
output, then runs it with `eval` and checks that it prints the file. It
also runs `read-file -- guide-skill -notes.md` directly.
- `acceptance/cmd/skills/disabled` already checks that the `skills`
group is not registered when `DATABRICKS_SKILLS_PREVIEW` is unset, so
the change is behind the guard.
- Not tested: the printed Windows form in Windows PowerShell 5.1,
because the acceptance script runs in bash on the Windows CI cell.
- `go test ./cmd/skills/... ./libs/skills/...` and `go test ./acceptance
-run TestAccept/cmd/skills` pass, and `./task fmt-q lint-q` is clean.
This pull request and its description were written by Isaac.
---------
Co-authored-by: Isaac <no-reply@databricks.com>1 parent cfd268f commit a0805a0
6 files changed
Lines changed: 52 additions & 3 deletions
File tree
- acceptance/cmd/skills
- read
- release
- skills/guide-skill
- cmd/skills
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
16 | 27 | | |
17 | 28 | | |
18 | 29 | | |
| |||
33 | 44 | | |
34 | 45 | | |
35 | 46 | | |
36 | | - | |
| 47 | + | |
| 48 | + | |
37 | 49 | | |
38 | 50 | | |
39 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
7 | 16 | | |
8 | 17 | | |
9 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
30 | 52 | | |
31 | 53 | | |
32 | 54 | | |
| |||
0 commit comments