add help description

This commit is contained in:
Georgi Knox 2019-05-14 13:28:06 -04:00 committed by Mike Farah
parent b2fe3e6738
commit 6e35356a84
6 changed files with 31 additions and 16 deletions

View File

@ -82,6 +82,8 @@ docker run -it -v ${PWD}:/workdir mikefarah/yq sh
Check out the [documentation](http://mikefarah.github.io/yq/) for more detailed and advanced usage. Check out the [documentation](http://mikefarah.github.io/yq/) for more detailed and advanced usage.
``` ```
yq is a lightweight and portable command-line YAML processor. It aims to be the jq or sed of yaml files.
Usage: Usage:
yq [flags] yq [flags]
yq [command] yq [command]
@ -91,9 +93,9 @@ Available Commands:
help Help about any command help Help about any command
merge yq m [--inplace/-i] [--doc/-d index] [--overwrite/-x] [--append/-a] sample.yaml sample2.yaml merge yq m [--inplace/-i] [--doc/-d index] [--overwrite/-x] [--append/-a] sample.yaml sample2.yaml
new yq n [--script/-s script_file] a.b.c newValue new yq n [--script/-s script_file] a.b.c newValue
prefix yq p [--inplace/-i] [--doc/-d index] sample.yaml a.b.c
read yq r [--doc/-d index] sample.yaml a.b.c read yq r [--doc/-d index] sample.yaml a.b.c
write yq w [--inplace/-i] [--script/-s script_file] [--doc/-d index] sample.yaml a.b.c newValue write yq w [--inplace/-i] [--script/-s script_file] [--doc/-d index] sample.yaml a.b.c newValue
prefix yq p [--inplace/-i] [--doc/-d index] sample.yaml a.b.c
Flags: Flags:
-h, --help help for yq -h, --help help for yq

View File

@ -24,7 +24,18 @@ func TestRootCmd(t *testing.T) {
if !strings.Contains(result.Output, "Usage:") { if !strings.Contains(result.Output, "Usage:") {
t.Error("Expected usage message to be printed out, but the usage message was not found.") t.Error("Expected usage message to be printed out, but the usage message was not found.")
} }
}
func TestRootCmd_Help(t *testing.T) {
cmd := getRootCommand()
result := runCmd(cmd, "--help")
if result.Error != nil {
t.Error(result.Error)
}
if !strings.Contains(result.Output, "yq is a lightweight and portable command-line YAML processor. It aims to be the jq or sed of yaml files.") {
t.Error("Expected usage message to be printed out, but the usage message was not found.")
}
} }
func TestRootCmd_VerboseLong(t *testing.T) { func TestRootCmd_VerboseLong(t *testing.T) {

File diff suppressed because one or more lines are too long

View File

@ -2,42 +2,42 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url> <url>
<loc>None</loc> <loc>None</loc>
<lastmod>2019-04-29</lastmod> <lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>None</loc> <loc>None</loc>
<lastmod>2019-04-29</lastmod> <lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>None</loc> <loc>None</loc>
<lastmod>2019-04-29</lastmod> <lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>None</loc> <loc>None</loc>
<lastmod>2019-04-29</lastmod> <lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>None</loc> <loc>None</loc>
<lastmod>2019-04-29</lastmod> <lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>None</loc> <loc>None</loc>
<lastmod>2019-04-29</lastmod> <lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>None</loc> <loc>None</loc>
<lastmod>2019-04-29</lastmod> <lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>None</loc> <loc>None</loc>
<lastmod>2019-04-29</lastmod> <lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
</urlset> </urlset>

Binary file not shown.

2
yq.go
View File

@ -41,6 +41,8 @@ func newCommandCLI() *cobra.Command {
yaml.DefaultMapType = reflect.TypeOf(yaml.MapSlice{}) yaml.DefaultMapType = reflect.TypeOf(yaml.MapSlice{})
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "yq", Use: "yq",
Short: "yq is a lightweight and portable command-line YAML processor.",
Long: `yq is a lightweight and portable command-line YAML processor. It aims to be the jq or sed of yaml files.`,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
if version { if version {
cmd.Print(GetVersionDisplay()) cmd.Print(GetVersionDisplay())