github.com/beauknowssoftware/makehcl@v0.0.0-20200322000747-1b9bb1e1c008/internal/cmd/exec.go (about)

     1  package cmd
     2  
     3  import "github.com/jessevdk/go-flags"
     4  
     5  func Exec() error {
     6  	p := flags.NewParser(nil, flags.Default)
     7  
     8  	var plan PlanCommand
     9  	_, err := p.AddCommand("plan",
    10  		"Plan execution",
    11  		"The plan command plans execution",
    12  		&plan)
    13  
    14  	if err != nil {
    15  		return err
    16  	}
    17  
    18  	var run RunCommand
    19  	_, err = p.AddCommand("run",
    20  		"Execute",
    21  		"The run command executes",
    22  		&run)
    23  
    24  	if err != nil {
    25  		return err
    26  	}
    27  
    28  	var targets TargetsCommand
    29  	_, err = p.AddCommand("targets",
    30  		"Display list of targets",
    31  		"The targets command displays a list of executable targets",
    32  		&targets)
    33  
    34  	if err != nil {
    35  		return err
    36  	}
    37  
    38  	var completion CompletionCommand
    39  	_, err = p.AddCommand("completion",
    40  		"Show completion script",
    41  		"The completion command prints a script that can be used for shell completion",
    42  		&completion)
    43  
    44  	if err != nil {
    45  		return err
    46  	}
    47  
    48  	var graph GraphCommand
    49  	_, err = p.AddCommand("graph",
    50  		"Print a graph",
    51  		"The graph command parses the make hcl file and prints a dot formatted graph",
    52  		&graph)
    53  
    54  	if err != nil {
    55  		return err
    56  	}
    57  
    58  	_, err = p.Parse()
    59  
    60  	return err
    61  }