Skip to content

Commit a2230c9

Browse files
authored
Merge pull request #3018 from carapace-sh/add-bash-declare
bash: added declare builtin
2 parents 2c0c6b8 + ae39c43 commit a2230c9

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package cmd
2+
3+
import (
4+
"github.com/carapace-sh/carapace"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
var rootCmd = &cobra.Command{
9+
Use: "declare",
10+
Short: "Declare variables and give them attributes",
11+
Run: func(cmd *cobra.Command, args []string) {},
12+
}
13+
14+
func Execute() error {
15+
return rootCmd.Execute()
16+
}
17+
func init() {
18+
carapace.Gen(rootCmd).Standalone()
19+
20+
rootCmd.Flags().BoolS("A", "A", false, "each name is an associative array variable")
21+
rootCmd.Flags().BoolS("F", "F", false, "inhibit the display of function definitions")
22+
rootCmd.Flags().BoolS("I", "I", false, "inherit the attributes and value of any existing variable with the same name")
23+
rootCmd.Flags().BoolS("a", "a", false, "each name is an indexed array variable")
24+
rootCmd.Flags().BoolS("f", "f", false, "each name refers to a shell function")
25+
rootCmd.Flags().BoolS("g", "g", false, "forces variables to be created or modified at the global scope")
26+
rootCmd.Flags().BoolS("i", "i", false, "the variable is to be treated as an integer")
27+
rootCmd.Flags().BoolS("l", "l", false, "all upper-case characters are converted to lower-case")
28+
rootCmd.Flags().BoolS("n", "n", false, "give each name the nameref attribute")
29+
rootCmd.Flags().BoolS("p", "p", false, "option will display the attributes and values of each name")
30+
rootCmd.Flags().BoolS("r", "r", false, "make names readonly")
31+
rootCmd.Flags().BoolS("t", "t", false, "give each name the trace attribute")
32+
rootCmd.Flags().BoolS("u", "u", false, "all lower-case characters are converted to upper-case")
33+
rootCmd.Flags().BoolS("x", "x", false, "mark each name for export to subsequent commands via the environment")
34+
35+
// TODO shell.Variables
36+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "github.com/carapace-sh/carapace-bin/completers/bash/declare_completer/cmd"
4+
5+
func main() {
6+
cmd.Execute()
7+
}

0 commit comments

Comments
 (0)