github.com/btwiuse/jiri@v0.0.0-20191125065820-53353bcfef54/cmdline/testdata/flags.go (about)

     1  // Copyright 2015 The Vanadium Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"fmt"
     9  
    10  	"github.com/btwiuse/jiri/cmdline"
    11  )
    12  
    13  // cmdFlags represents the flags command.
    14  var cmdFlags = &cmdline.Command{
    15  	Runner:   cmdline.RunnerFunc(runFlags),
    16  	Name:     "flags",
    17  	Short:    "Short description of command flags",
    18  	Long:     "Long description of command flags.",
    19  	ArgsName: "[args]",
    20  	ArgsLong: "[args] are ignored",
    21  }
    22  
    23  func runFlags(env *cmdline.Env, args []string) error {
    24  	fmt.Fprintf(env.Stdout, "global1=%q shared=%q local=%q %q\n", flagGlobal1, flagShared, flagLocal, args)
    25  	return nil
    26  }
    27  
    28  var (
    29  	flagGlobal1, flagShared, flagLocal string
    30  )
    31  
    32  func main() {
    33  	cmdFlags.Flags.StringVar(&flagGlobal1, "global1", "", "description of global1")
    34  	cmdFlags.Flags.StringVar(&flagShared, "shared", "", "description of shared")
    35  	cmdFlags.Flags.StringVar(&flagLocal, "local", "", "description of local")
    36  	cmdline.Main(cmdFlags)
    37  }