-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from halprin/set-endpoint
Use Custom Endpoint
- Loading branch information
Showing
7 changed files
with
79 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package config | ||
|
||
var tableName *string | ||
var dynamoDbEndpoint *string | ||
|
||
func SetTableName(name string) { | ||
tableName = &name | ||
} | ||
|
||
func GetTableName() *string { | ||
return tableName | ||
} | ||
|
||
func SetDynamoDbEndpoint(endpoint string) { | ||
dynamoDbEndpoint = &endpoint | ||
} | ||
|
||
func GetDynamoDbEndpoint() *string { | ||
return dynamoDbEndpoint | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/halprin/delete-dynamodb-items/config" | ||
"github.com/teris-io/cli" | ||
"os" | ||
) | ||
|
||
func FillConfig() { | ||
endpointKey := "endpoint" | ||
tableNameCliArg := cli.NewArg("table name", "The name of the table for which all the items will be deleted").WithType(cli.TypeString) | ||
endpointCliOption := cli.NewOption(endpointKey, "A URL of the DynamoDB endpoint to use").WithChar('e').WithType(cli.TypeString) | ||
|
||
parser := cli.New("Deletes all the items in a DynamoDB table").WithArg(tableNameCliArg).WithOption(endpointCliOption) | ||
|
||
invocation, arguments, options, err := parser.Parse(os.Args) | ||
help, helpExistsInOptions := options["help"] | ||
|
||
if err != nil { | ||
_ = parser.Usage(invocation, os.Stdout) | ||
os.Exit(1) | ||
} else if helpExistsInOptions && help == "true" { | ||
_ = parser.Usage(invocation, os.Stdout) | ||
os.Exit(0) | ||
} | ||
|
||
tableName := arguments[0] | ||
config.SetTableName(tableName) | ||
|
||
endpoint, endpointExistsInOptions := options[endpointKey] | ||
if endpointExistsInOptions { | ||
config.SetDynamoDbEndpoint(endpoint) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters