-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added support for displaying subcommand descriptions and help texts.
- Updated readme.
- Loading branch information
Kristoffer Ahl
committed
Jan 28, 2020
1 parent
9f2281b
commit 8bb3c37
Showing
9 changed files
with
163 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
# centry.cmd.description/get:env=Prints environment variables | ||
# centry.cmd.help/get:env=Prints environment variables. Usage: ./stack get env [<...options>] | ||
get:env() { | ||
env | ${SORTED} | ||
} | ||
|
||
# centry.cmd.description/get:files=Prints files from the current working directory | ||
# centry.cmd.help/get:files=Prints files from the current working directory. Usage: ./stack get files [<...options>] | ||
get:files() { | ||
ls -ahl | ${SORTED} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
rotate:secrets () { | ||
# centry.cmd.description/rotate:secrets=Rotate secrets | ||
rotate:secrets() { | ||
echo "rotate:secrets ($*)" | ||
} | ||
|
||
rotate:kubernetes:nodes () { | ||
echo "rotate:kubernetes:nodes ($*)" | ||
# centry.cmd.description/rotate:kubernetes:workers=Rotate kubernetes worker nodes | ||
rotate:kubernetes:workers() { | ||
echo "rotate:kubernetes:workers ($*)" | ||
} | ||
|
||
rotate:kubernetes:masters () { | ||
# centry.cmd.description/rotate:kubernetes:masters=Rotate kubernetes master nodes | ||
rotate:kubernetes:masters() { | ||
echo "rotate:kubernetes;masters ($*)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,59 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// TrueString defines a true value | ||
const TrueString string = "true" | ||
|
||
// APIServeAnnotation defines an annotation | ||
const APIServeAnnotation string = "centry.api/serve" | ||
// CommandAnnotationAPIServe defines an annotation | ||
const CommandAnnotationAPIServe string = "centry.api/serve" | ||
|
||
// CommandAnnotationDescriptionNamespace denines an annotation namespace | ||
const CommandAnnotationDescriptionNamespace string = "centry.cmd.description" | ||
|
||
// CommandAnnotationHelpNamespace denines an annotation namespace | ||
const CommandAnnotationHelpNamespace string = "centry.cmd.help" | ||
|
||
// CommandAnnotationNamespaces holds a list of command annotation namespaces | ||
var CommandAnnotationNamespaces = []string{ | ||
CommandAnnotationDescriptionNamespace, | ||
CommandAnnotationHelpNamespace, | ||
} | ||
|
||
// Annotation defines an annotation | ||
type Annotation struct { | ||
Namespace string | ||
Key string | ||
Value string | ||
} | ||
|
||
// ParseAnnotation parses text into an annotation | ||
func ParseAnnotation(text string) (*Annotation, error) { | ||
text = strings.TrimSpace(text) | ||
|
||
if !strings.HasPrefix(text, "centry") || !strings.Contains(text, "=") || !strings.Contains(text, "/") { | ||
return nil, nil | ||
} | ||
|
||
kvp := strings.Split(text, "=") | ||
if len(kvp) != 2 { | ||
return nil, fmt.Errorf("Failed to parse annotation! The text \"%s\" is not a valid annotation", text) | ||
} | ||
|
||
nk := kvp[0] | ||
v := kvp[1] | ||
|
||
nkkvp := strings.Split(nk, "/") | ||
if len(nkkvp) != 2 { | ||
return nil, fmt.Errorf("Failed to parse annotation! The text \"%s\" is not a valid annotation", text) | ||
} | ||
|
||
return &Annotation{ | ||
Namespace: nkkvp[0], | ||
Key: nkkvp[1], | ||
Value: v, | ||
}, nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters