github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/cli/cli.go (about)

     1  // Package cli provides a minimal framework for creating and organizing command line
     2  // Go applications. cli is designed to be easy to understand and write, the most simple
     3  // cli application can be written as follows:
     4  //   func main() {
     5  //     cli.NewApp().Run(os.Args)
     6  //   }
     7  //
     8  // Of course this application does not do much, so let's make this an actual application:
     9  //   func main() {
    10  //     app := cli.NewApp()
    11  //     app.Name = "greet"
    12  //     app.Usage = "say a greeting"
    13  //     app.Action = func(c *cli.Context) {
    14  //       println("Greetings")
    15  //     }
    16  //
    17  //     app.Run(os.Args)
    18  //   }
    19  package cli
    20  
    21  import (
    22  	"strings"
    23  )
    24  
    25  type MultiError struct {
    26  	Errors []error
    27  }
    28  
    29  func NewMultiError(err ...error) MultiError {
    30  	return MultiError{Errors: err}
    31  }
    32  
    33  func (m MultiError) Error() string {
    34  	errs := make([]string, len(m.Errors))
    35  	for i, err := range m.Errors {
    36  		errs[i] = err.Error()
    37  	}
    38  
    39  	return strings.Join(errs, "\n")
    40  }