Skip to content

Commit f0f00bd

Browse files
committed
fish: completions: korg_gcc: Complete arch in var if ARCH= exists
Signed-off-by: Nathan Chancellor <[email protected]>
1 parent f6a2404 commit f0f00bd

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

fish/completions/korg_gcc.fish

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
set -l commands install latest folder var
22

3+
function __korg_gcc_get_kmake_arch
4+
set tokens (commandline -cx)
5+
if test "$tokens[1]" != kmake
6+
return 1
7+
end
8+
9+
for token in $tokens[2..]
10+
if string match -qr -- '^ARCH=(?<value>.*)$' $token
11+
echo $value
12+
return 0
13+
end
14+
end
15+
16+
return 1
17+
end
18+
319
function __korg_gcc_get_targets
420
PYTHONPATH=$PYTHON_SCRIPTS_FOLDER python3 -c "from korg_tc import GCCManager
521
print('\n'.join(GCCManager.TARGETS))"
622
end
723

24+
function __korg_gcc_get_targets_for_var
25+
if set arch (__korg_gcc_get_kmake_arch)
26+
echo $arch
27+
else
28+
__korg_gcc_get_targets
29+
end
30+
end
31+
832
function __korg_gcc_get_versions
933
PYTHONPATH=$PYTHON_SCRIPTS_FOLDER python3 -c "from korg_tc import GCCManager
1034
print('\n'.join(map(str, GCCManager.VERSIONS)))"
@@ -44,5 +68,5 @@ complete -c korg_gcc -n "__fish_seen_subcommand_from install" -f -l no-extract -
4468

4569
complete -c korg_gcc -n "__fish_seen_subcommand_from latest" -f -d "Major version" -a '(__korg_gcc_get_versions)'
4670

47-
complete -c korg_gcc -n "__fish_seen_subcommand_from var; and not __korg_gcc_seen_target" -f -d Target -a '(__korg_gcc_get_targets)'
71+
complete -c korg_gcc -n "__fish_seen_subcommand_from var; and not __korg_gcc_seen_target" -f -d Target -a '(__korg_gcc_get_targets_for_var)'
4872
complete -c korg_gcc -n "__fish_seen_subcommand_from var; and __korg_gcc_seen_target" -f -d Version -a '(__korg_gcc_get_versions)'

0 commit comments

Comments
 (0)