-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrava-completion.bash
More file actions
55 lines (48 loc) · 1.83 KB
/
strava-completion.bash
File metadata and controls
55 lines (48 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
# Bash completion script for strava CLI
_strava_completions() {
local cur prev commands
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Main commands
commands="init athlete stats zones activities activity streams laps azones comments kudos last today week segment starred explore efforts effort gear route routes"
# Common options
local common_opts="--raw --output --quiet --pretty --help"
# If we're completing the first argument (command)
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
return 0
fi
# Command-specific completions
case "${COMP_WORDS[1]}" in
activity)
COMPREPLY=( $(compgen -W "--efforts ${common_opts}" -- ${cur}) )
;;
activities|starred|routes)
COMPREPLY=( $(compgen -W "--page --per-page ${common_opts}" -- ${cur}) )
;;
explore)
COMPREPLY=( $(compgen -W "--bounds --type --min-cat --max-cat ${common_opts}" -- ${cur}) )
;;
efforts)
COMPREPLY=( $(compgen -W "--segment --start --end --per-page ${common_opts}" -- ${cur}) )
;;
streams)
# Stream types
if [ $COMP_CWORD -gt 2 ]; then
local stream_types="time distance latlng altitude velocity_smooth heartrate cadence watts temp moving grade_smooth"
COMPREPLY=( $(compgen -W "${stream_types}" -- ${cur}) )
fi
;;
*)
COMPREPLY=( $(compgen -W "${common_opts}" -- ${cur}) )
;;
esac
# Complete file paths for --output
if [[ ${prev} == "--output" || ${prev} == "-o" ]]; then
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
fi
}
complete -F _strava_completions strava