Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Commit

Permalink
added ec2 subcommand. Closes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
bharath-srinivas committed Feb 2, 2018
1 parent 95c32a7 commit 3712e33
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ available EC2 instances in a table like structure excluding the ones that are be
List all the available EC2 instances:

```bash
$ aws-go list
$ aws-go ec2 list
```

### Starting EC2 instances
Expand All @@ -214,13 +214,13 @@ the `start` command along with the `instance-id` of the instance you want to sta
Starting an EC2 instance:

```bash
$ aws-go start i-0a12b345c678de
$ aws-go ec2 start i-0a12b345c678de
```

Performing a `--dry-run` operation:

```bash
$ aws-go start --dry-run i-0a12b345c678de
$ aws-go ec2 start --dry-run i-0a12b345c678de
```

### Stopping EC2 instances
Expand All @@ -233,13 +233,13 @@ as the argument.
Stopping an EC2 instance:

```bash
$ aws-go stop i-0a12b345c678de
$ aws-go ec2 stop i-0a12b345c678de
```

Performing a `--dry-run` operation:

```bash
$ aws-go stop --dry-run i-0a12b345c678de
$ aws-go ec2 stop --dry-run i-0a12b345c678de
```

### Listing Lambda functions
Expand Down
26 changes: 26 additions & 0 deletions cmd/aws-go/ec2/ec2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Package ec2 implements AWS EC2 related operations.
package ec2

import (
"github.com/spf13/cobra"

"github.com/bharath-srinivas/aws-go/cmd/aws-go/command"
)

// ec2 command.
var ec2Cmd = &cobra.Command{
Use: "ec2",
Short: "Perform AWS EC2 specific operations",
Long: `List, start or stop AWS EC2 instances`,
Example: ` aws-go ec2 list
aws-go ec2 start i-0a12b345c678de
aws-go ec2 stop i-0a12b345c678de`,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
cmd.Usage()
},
}

func init() {
command.AddCommand(ec2Cmd)
}
2 changes: 1 addition & 1 deletion cmd/aws-go/ec2/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var listCmd = &cobra.Command{
}

func init() {
command.AddCommand(listCmd)
ec2Cmd.AddCommand(listCmd)
}

// run command.
Expand Down
2 changes: 1 addition & 1 deletion cmd/aws-go/ec2/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var startCmd = &cobra.Command{
}

func init() {
command.AddCommand(startCmd)
ec2Cmd.AddCommand(startCmd)
startCmd.Flags().BoolVarP(&dryRun, "dry-run", "", false, "perform the operation with dry run enabled")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/aws-go/ec2/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var stopCmd = &cobra.Command{
}

func init() {
command.AddCommand(stopCmd)
ec2Cmd.AddCommand(stopCmd)
stopCmd.Flags().BoolVarP(&dryRun, "dry-run", "", false, "perform the operation with dry run enabled")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/aws-go/rds/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
var rdsCmd = &cobra.Command{
Use: "rds",
Short: "Perform AWS RDS specific operations",
Long: `List, start or stop AWS RDS instances`,
Long: `List AWS RDS instances`,
Args: cobra.NoArgs,
Example: ` aws-go rds list`,
Run: func(cmd *cobra.Command, args []string) {
Expand Down

0 comments on commit 3712e33

Please sign in to comment.