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

@ -1,4 +1,4 @@
# yq
# yq
[![Build Status](https://travis-ci.org/mikefarah/yq.svg?branch=master)](https://travis-ci.org/mikefarah/yq) ![Docker Pulls](https://img.shields.io/docker/pulls/mikefarah/yq.svg) ![Github Releases (by Release)](https://img.shields.io/github/downloads/mikefarah/yq/total.svg)
@ -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.
```
yq is a lightweight and portable command-line YAML processor. It aims to be the jq or sed of yaml files.
Usage:
yq [flags]
yq [command]
@ -91,9 +93,9 @@ Available Commands:
help Help about any command
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
prefix yq p [--inplace/-i] [--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
prefix yq p [--inplace/-i] [--doc/-d index] sample.yaml a.b.c
Flags:
-h, --help help for yq
@ -110,8 +112,8 @@ Use "yq [command] --help" for more information about a command.
3. add unit tests
4. apply changes (use govendor with a preference to [gopkg](https://gopkg.in/) for package dependencies)
5. `make [local] build`
6. If required, update the user documentation
6. If required, update the user documentation
- Update README.md and/or documentation under the mkdocs folder
- `make [local] build-docs`
- browse to docs/index.html and check your changes
- browse to docs/index.html and check your changes
7. profit

View File

@ -24,7 +24,18 @@ func TestRootCmd(t *testing.T) {
if !strings.Contains(result.Output, "Usage:") {
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) {
@ -906,9 +917,9 @@ func TestDeleteSplatArrayYaml(t *testing.T) {
content := `a: 2
b:
hi:
- thing: item1
- thing: item1
name: fred
- thing: item2
- thing: item2
name: sam
`
filename := writeTempYamlFile(content)

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">
<url>
<loc>None</loc>
<lastmod>2019-04-29</lastmod>
<lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>None</loc>
<lastmod>2019-04-29</lastmod>
<lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>None</loc>
<lastmod>2019-04-29</lastmod>
<lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>None</loc>
<lastmod>2019-04-29</lastmod>
<lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>None</loc>
<lastmod>2019-04-29</lastmod>
<lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>None</loc>
<lastmod>2019-04-29</lastmod>
<lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>None</loc>
<lastmod>2019-04-29</lastmod>
<lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>None</loc>
<lastmod>2019-04-29</lastmod>
<lastmod>2019-05-14</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>

Binary file not shown.

4
yq.go
View File

@ -40,7 +40,9 @@ func main() {
func newCommandCLI() *cobra.Command {
yaml.DefaultMapType = reflect.TypeOf(yaml.MapSlice{})
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 {
if version {
cmd.Print(GetVersionDisplay())