Skip to content

Commit

Permalink
Merge branch '1-implement-the-ws-flag' into 'master'
Browse files Browse the repository at this point in the history
Implement new workspace usage for create/update/maintain

Closes #1

See merge request !2
  • Loading branch information
clarsonneur authored and ChristopheLarsonneur committed Oct 6, 2016
2 parents c85a8a9 + 6731d2a commit 932f3ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ func (a *Forj) init() {
contribs_repo := map[string]interface{}{"envar": "CONTRIBS_REPO"}
repotemplates_repo := map[string]interface{}{"envar": "REPOTEMPLATES_REPO"}
flows_repo := map[string]interface{}{"envar": "FLOWS_REPO"}
// required := map[string]interface{}{"required": true}
required := map[string]interface{}{"required": true}
ssh_dir_opts := map[string]interface{}{"default": fmt.Sprintf("%s/.ssh", os.Getenv("HOME"))}
no_set_value_opts := map[string]interface{}{"set_value": false}

a.SetCommand("create", create_action_help)
a.SetCmdArg("create", "workspace", create_orga_help, no_opts)
a.SetCmdArg("create", "workspace", create_orga_help, required)
a.SetCmdFlag("create", ssh_dir_flag_name, create_ssh_dir_help, ssh_dir_opts)
a.SetCmdFlag("create", "contribs-repo", contribs_repo_help, contribs_repo)
a.SetCmdFlag("create", "flows-repo", flows_repo_help, flows_repo)
Expand All @@ -176,7 +176,7 @@ func (a *Forj) init() {
We could probably use this update to add repositories or migrate the solution to a different place. */
a.SetCommand("update", update_action_help)
a.SetCmdArg("update", "workspace", update_orga_help, no_opts)
a.SetCmdFlag("update", "ws", update_orga_help, no_opts)
a.SetCmdFlag("update", ssh_dir_flag_name, update_ssh_dir_help, ssh_dir_opts)
a.SetCmdFlag("update", "contribs-repo", contribs_repo_help, contribs_repo)
a.SetCmdFlag("update", "flows-repo", flows_repo_help, flows_repo)
Expand All @@ -197,7 +197,7 @@ func (a *Forj) init() {
The technology to ensure (orchestration), could be puppet/ansible combined with docker.
This is not fully defined. */
a.SetCommand("maintain", maintain_action_help)
a.SetCmdArg("maintain", "workspace", maintain_orga_help, no_opts)
a.SetCmdFlag("maintain", "ws", maintain_orga_help, no_opts)
a.SetCmdFlag("maintain", "infra_url", maintain_infra_url_help, no_opts)
// FUTURE: Difficulty: 2. Provide a way to expose options defined in the maintain option file as CLI maintain flags.
a.SetCmdFlag("maintain", "file", maintain_option_file, no_opts)
Expand Down
11 changes: 10 additions & 1 deletion cli_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ func (a *Forj) LoadContext(args []string) {
Workspace := ""
Workspace_path := ""
// The value is not set in argsv. But is in the parser context.
if orga, found := a.argValue(context, opts.args["workspace"]); found {
var orga string
var found bool

if opts.name == "create" {
orga, found = a.argValue(context, opts.args["workspace"])
} else {
orga, found = a.flagValue(context, opts.flags["ws"])
}

if found {
orga = path.Clean(orga)
Workspace = path.Base(orga)
Workspace_path = path.Dir(orga)
Expand Down

0 comments on commit 932f3ed

Please sign in to comment.