Skip to content

feat: Add flags create command#56

Merged
dbolson merged 3 commits intomainfrom
sc-235703/create-flag
Mar 22, 2024
Merged

feat: Add flags create command#56
dbolson merged 3 commits intomainfrom
sc-235703/create-flag

Conversation

@dbolson
Copy link
Copy Markdown
Contributor

@dbolson dbolson commented Mar 22, 2024

Adds a flags create command similar to projects create. We'll use this in the setup wizard.

@shortcut-integration
Copy link
Copy Markdown

This pull request has been linked to Shortcut Story #235703: create command to create a new flag.

@dbolson dbolson changed the title Add flags create command feat: Add flags create command Mar 22, 2024
Comment thread cmd/flags/create.go
"ld-cli/internal/flags"
)

func NewCreateCmd() *cobra.Command {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as the projects version only it calls the flags API.

Comment thread cmd/flags/create.go Outdated
panic(err)
}

cmd.Flags().String("projKey", "", "Input data in JSON")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new flag since we need it to create a feature flag.

Comment thread cmd/flags/create.go

var data inputData
err := json.Unmarshal([]byte(cmd.Flags().Lookup("data").Value.String()), &data)
// err := json.Unmarshal([]byte(viper.GetString("data")), &data)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this isn't populating. I'll come back to it later.

Comment thread cmd/projects/create.go
"",
"Input data in JSON",
)
cmd.Flags().StringP("data", "d", "", "Input data in JSON")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the local var, so I changed the function.

Comment thread cmd/projects/create.go

var data inputData
err := json.Unmarshal([]byte(dataStr), &data)
err := json.Unmarshal([]byte(viper.GetString("data")), &data)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined var.

Comment thread internal/flags/flags.go
"ld-cli/internal/errors"
)

type Client interface {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may not need a client per resource, but it does keep the interfaces smaller than one big one.

}

func (m flagToggleModel) toggleFlag() error {
func (m flagToggleModel) toggleFlag() error { //nolint:unused
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added these for the pre-commit linter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty!!

Comment thread cmd/flags/create.go Outdated
panic(err)
}

cmd.Flags().String("projKey", "", "Input data in JSON")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmd.Flags().String("projKey", "", "Input data in JSON")
cmd.Flags().String("projKey", "", "Project key string")

Comment thread internal/flags/flags.go Outdated
Comment on lines +42 to +43
fmt.Println(">>> err")
spew.Dump(err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left in some debugging statements

}

func (m flagToggleModel) toggleFlag() error {
func (m flagToggleModel) toggleFlag() error { //nolint:unused
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants