mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-03 04:17:54 +00:00
fix(completion): close shell completion review gaps
This commit is contained in:
@@ -137,7 +137,7 @@ $ ccs auth show <TAB>
|
|||||||
work personal team --json
|
work personal team --json
|
||||||
|
|
||||||
$ ccs api <TAB>
|
$ ccs api <TAB>
|
||||||
create discover copy export import remove
|
create list discover copy export import remove
|
||||||
```
|
```
|
||||||
|
|
||||||
### Backend Contract
|
### Backend Contract
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ function __fish_ccs_complete
|
|||||||
end
|
end
|
||||||
|
|
||||||
set -l current (commandline -ct)
|
set -l current (commandline -ct)
|
||||||
|
if test -n "$current"; and test (count $tokens_before_current) -gt 0; and test "$tokens_before_current[-1]" = "$current"
|
||||||
|
set -e tokens_before_current[-1]
|
||||||
|
end
|
||||||
|
|
||||||
set -l script_file (status filename)
|
set -l script_file (status filename)
|
||||||
set -l repo_root (realpath (dirname $script_file)/../.. 2>/dev/null)
|
set -l repo_root (realpath (dirname $script_file)/../.. 2>/dev/null)
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
|
||||||
import { describe, it, expect, beforeAll, beforeEach, afterEach, mock } from 'bun:test';
|
import { describe, it, expect, beforeAll, beforeEach, afterEach, mock } from 'bun:test';
|
||||||
|
|
||||||
type ShellTarget = 'bash' | 'zsh' | 'fish' | 'powershell' | null;
|
type ShellTarget = 'bash' | 'zsh' | 'fish' | 'powershell' | null;
|
||||||
@@ -139,4 +142,15 @@ describe('shell-completion command', () => {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('fish completion strips a duplicated partial token before delegating to __complete', () => {
|
||||||
|
const fishScript = readFileSync(
|
||||||
|
join(import.meta.dir, '../../../scripts/completion/ccs.fish'),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(fishScript).toContain('set -l current (commandline -ct)');
|
||||||
|
expect(fishScript).toContain('test "$tokens_before_current[-1]" = "$current"');
|
||||||
|
expect(fishScript).toContain('set -e tokens_before_current[-1]');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user