github.com/devcamcar/cli@v0.0.0-20181107134215-706a05759d18/objects/context/commands.go (about)

     1  package context
     2  
     3  import "github.com/urfave/cli"
     4  
     5  func Create() cli.Command {
     6  	return cli.Command{
     7  		Name:        "context",
     8  		Usage:       "Create a new context",
     9  		Aliases:     []string{"ctx"},
    10  		ArgsUsage:   "<context>",
    11  		Category:    "MANAGEMENT COMMAND",
    12  		Description: "This command creates a new context for a created application.",
    13  		Action:      createCtx,
    14  		Flags: []cli.Flag{
    15  			cli.StringFlag{
    16  				Name:  "provider",
    17  				Usage: "Context provider",
    18  			},
    19  			cli.StringFlag{
    20  				Name:  "api-url",
    21  				Usage: "Context api url",
    22  			},
    23  			cli.StringFlag{
    24  				Name:  "registry",
    25  				Usage: "Context registry",
    26  			},
    27  		},
    28  	}
    29  }
    30  
    31  func List() cli.Command {
    32  	return cli.Command{
    33  		Name:        "contexts",
    34  		Usage:       "List contexts",
    35  		Aliases:     []string{"context", "ctx"},
    36  		Category:    "MANAGEMENT COMMAND",
    37  		Description: "This command returns a list of contexts.",
    38  		Action:      listCtx,
    39  		Flags: []cli.Flag{
    40  			cli.StringFlag{
    41  				Name:  "output",
    42  				Usage: "Output format (json)",
    43  				Value: "",
    44  			},
    45  		},
    46  	}
    47  }
    48  
    49  func Delete() cli.Command {
    50  	return cli.Command{
    51  		Name:        "context",
    52  		Usage:       "Delete a context",
    53  		Aliases:     []string{"ctx"},
    54  		ArgsUsage:   "<context>",
    55  		Description: "This command deletes a context.",
    56  		Category:    "MANAGEMENT COMMAND",
    57  		Action:      deleteCtx,
    58  	}
    59  }
    60  
    61  func Inspect() cli.Command {
    62  	return cli.Command{
    63  		Name:     "context",
    64  		Usage:    "Inspect the contents of a context, if no context is specified the current-context will be used.",
    65  		Aliases:  []string{"ctx"},
    66  		Category: "MANAGEMENT COMMAND",
    67  		Action:   inspectCtx,
    68  	}
    69  }
    70  
    71  func Update() cli.Command {
    72  	ctxMap := ContextMap{}
    73  	return cli.Command{
    74  		Name:        "context",
    75  		Usage:       "Update context files",
    76  		Aliases:     []string{"ctx"},
    77  		ArgsUsage:   "<key> [value]",
    78  		Category:    "MANAGEMENT COMMAND",
    79  		Description: "This command updates the current context file.",
    80  		Action:      ctxMap.updateCtx,
    81  		Flags: []cli.Flag{
    82  			cli.BoolFlag{
    83  				Name:  "delete",
    84  				Usage: "Delete key=value pair from context file.",
    85  			},
    86  		},
    87  	}
    88  }
    89  
    90  func Use() cli.Command {
    91  	return cli.Command{
    92  		Name:        "context",
    93  		Usage:       "Use context for future invocations",
    94  		Aliases:     []string{"ctx"},
    95  		ArgsUsage:   "<context>",
    96  		Category:    "MANAGEMENT COMMAND",
    97  		Description: "This command uses context for future invocations.",
    98  		Action:      useCtx,
    99  	}
   100  }
   101  
   102  func Unset() cli.Command {
   103  	return cli.Command{
   104  		Name:        "context",
   105  		Usage:       "Unset current-context",
   106  		Aliases:     []string{"ctx"},
   107  		Category:    "MANAGEMENT COMMAND",
   108  		Description: "This command unsets the current context in use.",
   109  		Action:      unsetCtx,
   110  	}
   111  }