github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/internal/objabi/flag.go (about)

     1  // Copyright 2015 The Go 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 objabi
     6  
     7  import (
     8  	"github.com/shogo82148/std/io"
     9  )
    10  
    11  func Flagcount(name, usage string, val *int)
    12  
    13  func Flagfn1(name, usage string, f func(string))
    14  
    15  func Flagprint(w io.Writer)
    16  
    17  func Flagparse(usage func())
    18  
    19  func AddVersionFlag()
    20  
    21  // DecodeArg decodes an argument.
    22  //
    23  // This function is public for testing with the parallel encoder.
    24  func DecodeArg(arg string) string
    25  
    26  type DebugFlag struct {
    27  	tab          map[string]debugField
    28  	concurrentOk *bool
    29  	debugSSA     DebugSSA
    30  }
    31  
    32  // A DebugSSA function is called to set a -d ssa/... option.
    33  // If nil, those options are reported as invalid options.
    34  // If DebugSSA returns a non-empty string, that text is reported as a compiler error.
    35  // If phase is "help", it should print usage information and terminate the process.
    36  type DebugSSA func(phase, flag string, val int, valString string) string
    37  
    38  // NewDebugFlag constructs a DebugFlag for the fields of debug, which
    39  // must be a pointer to a struct.
    40  //
    41  // Each field of *debug is a different value, named for the lower-case of the field name.
    42  // Each field must be an int or string and must have a `help` struct tag.
    43  // There may be an "Any bool" field, which will be set if any debug flags are set.
    44  //
    45  // The returned flag takes a comma-separated list of settings.
    46  // Each setting is name=value; for ints, name is short for name=1.
    47  //
    48  // If debugSSA is non-nil, any debug flags of the form ssa/... will be
    49  // passed to debugSSA for processing.
    50  func NewDebugFlag(debug interface{}, debugSSA DebugSSA) *DebugFlag
    51  
    52  func (f *DebugFlag) Set(debugstr string) error
    53  
    54  func (f *DebugFlag) String() string