mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 02:11:28 +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
|
||||
|
||||
$ ccs api <TAB>
|
||||
create discover copy export import remove
|
||||
create list discover copy export import remove
|
||||
```
|
||||
|
||||
### Backend Contract
|
||||
|
||||
@@ -7,6 +7,9 @@ function __fish_ccs_complete
|
||||
end
|
||||
|
||||
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 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';
|
||||
|
||||
type ShellTarget = 'bash' | 'zsh' | 'fish' | 'powershell' | null;
|
||||
@@ -139,4 +142,15 @@ describe('shell-completion command', () => {
|
||||
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