pkg.re/essentialkaos/ek.10@v12.41.0+incompatible/usage/completion/zsh/examples_test.go (about)

     1  package zsh
     2  
     3  // ////////////////////////////////////////////////////////////////////////////////// //
     4  //                                                                                    //
     5  //                         Copyright (c) 2022 ESSENTIAL KAOS                          //
     6  //      Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>     //
     7  //                                                                                    //
     8  // ////////////////////////////////////////////////////////////////////////////////// //
     9  
    10  import (
    11  	"fmt"
    12  
    13  	"pkg.re/essentialkaos/ek.v12/options"
    14  	"pkg.re/essentialkaos/ek.v12/usage"
    15  )
    16  
    17  // ////////////////////////////////////////////////////////////////////////////////// //
    18  
    19  func ExampleGenerate() {
    20  	info := usage.NewInfo()
    21  
    22  	info.AddCommand("test", "Test data")
    23  	info.AddCommand("clean", "Clean data")
    24  
    25  	info.AddOption("d:dir", "Path to working directory", "dir")
    26  
    27  	info.BoundOptions("test", "d:dir")
    28  	info.BoundOptions("clean", "d:dir")
    29  
    30  	info.AddOption("nc:no-color", "Disable colors in output")
    31  	info.AddOption("h:help", "Show this help message")
    32  	info.AddOption("v:version", "Show version")
    33  
    34  	opts := options.Map{
    35  		"d:dir":       {},
    36  		"nc:no-color": {Type: options.BOOL},
    37  		"h:help":      {Type: options.BOOL},
    38  		"v:version":   {Type: options.BOOL},
    39  	}
    40  
    41  	fmt.Println(Generate(info, opts, "app", "*.txt"))
    42  }