File tree 6 files changed +556
-4
lines changed
6 files changed +556
-4
lines changed Original file line number Diff line number Diff line change 1
1
= arduino-cli
2
+ Alessandro Sanino <a .sanino@bcmi-labs.cc >
2
3
3
4
Arduino CLI is a tool to access all Arduino Create API from Command Line.
4
5
It implements all functions provided by web version of Arduino Create.
@@ -9,10 +10,10 @@ It implements all functions provided by web version of Arduino Create.
9
10
. Reload shell configuration or reboot
10
11
And you're done, now let's see how to use the CLI.
11
12
12
- == Usage
13
+ == Usage : An example
13
14
14
15
A general call is `arduino [COMMAND] [options]`
15
- To see the full list of commands, call `arduino -h` or `arduino --help`
16
+ To see the full list of commands, call `arduino help [COMMAND]`, arduino [COMMAND] -h` or `arduino [COMMAND] --help`
16
17
17
18
== Contribution
18
19
Original file line number Diff line number Diff line change @@ -38,6 +38,30 @@ import (
38
38
"github.com/spf13/viper"
39
39
)
40
40
41
+ const bashAutoCompletionFunction = `
42
+ __arduino_autocomplete()
43
+ {
44
+ case $(last_command) in
45
+ arduino_lib)
46
+ opts="install uninstall list search version"
47
+ ;;
48
+ arduino_lib_list)
49
+ opts="update"
50
+ ;;
51
+ arduino_help)
52
+ opts="lib core version"
53
+ ;;
54
+ arduino)
55
+ opts="lib help version"
56
+ ;;
57
+ esac
58
+ if [[ ${cur} == " *" ]] ; then
59
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
60
+ return 0
61
+ fi
62
+ return 1
63
+ }`
64
+
41
65
// GlobalFlags represents flags available in all the program.
42
66
var GlobalFlags struct {
43
67
Verbose int
@@ -53,13 +77,14 @@ var RootCmd = &cobra.Command{
53
77
Use : "arduino" ,
54
78
Short : "Arduino CLI" ,
55
79
Long : "Arduino Create Command Line Interface (arduino-cli)" ,
80
+ BashCompletionFunction : bashAutoCompletionFunction ,
56
81
}
57
82
58
83
// Execute adds all child commands to the root command sets flags appropriately.
59
84
// This is called by main.main(). It only needs to happen once to the rootCmd.
60
85
func Execute () {
61
86
if err := RootCmd .Execute (); err != nil {
62
- fmt .Println (err )
87
+ // fmt.Println(err)
63
88
os .Exit (1 )
64
89
}
65
90
}
Original file line number Diff line number Diff line change
1
+ = Bash Autocompletion
2
+ Alessandro Sanino <a .sanino@bcmi-labs.cc >
3
+
4
+ File contained in this directory is the file to allow autocompletion of the arduino CLI commands
5
+
6
+ == Installation
7
+ . Move the file (using `sudo`) to directory `/etc/bash_completion.d`
8
+ [source, bash]
9
+ ----
10
+ sudo mv $PROJECT_DIR/docs/bash_completion/arduino /etc/bash_completion.d/
11
+ ----
12
+
13
+ . Reload bash completion configuration :
14
+ [source, bash]
15
+ ----
16
+ source /etc/bash_completion
17
+ . /etc/bash_completion.d/arduino
18
+ ----
19
+
20
+ . Requires `$PROJECT_DIR` in `PATH` environment variable
21
+ [source, bash]
22
+ ----
23
+ export PATH=$PATH:$PROJECT_DIR
24
+ ----
25
+
26
+ == How has been autocompletion obtained?
27
+ It has been obtained by setting up the BashAutocompletionFunction field of Root Command
28
+
29
+ ```
30
+
31
+ ```
You can’t perform that action at this time.
0 commit comments