-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow printing a command-line equivalent of a command #173
Allow printing a command-line equivalent of a command #173
Conversation
Based, based on #172. |
8d41290
to
9cd09e2
Compare
utils/cmdline.go
Outdated
func MaybeCurlAndExit(req client.AstarteRequest, client *client.Client) { | ||
if viper.GetBool("appengine-to-curl") || viper.GetBool("housekeeping-to-curl") || viper.GetBool("pairing-to-curl") || viper.GetBool("realmmanagement-to-curl") { | ||
fmt.Println(req.ToCurl(client)) | ||
os.Exit(0) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of duplicating the implementation, why not
func MaybeCurlAndExit(req client.AstarteRequest, client *client.Client) { | |
if viper.GetBool("appengine-to-curl") || viper.GetBool("housekeeping-to-curl") || viper.GetBool("pairing-to-curl") || viper.GetBool("realmmanagement-to-curl") { | |
fmt.Println(req.ToCurl(client)) | |
os.Exit(0) | |
} | |
} | |
func MaybeCurlAndExit(req client.AstarteRequest, client *client.Client) { | |
MaybeCurl(req, client) | |
os.Exit(0) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's no good because MaybeCurlAndExit
would exit even if all *-to-curl
are false. Using something like
func ShouldCurl() bool {
return viper.GetBool("appengine-to-curl") || viper.GetBool("housekeeping-to-curl") || viper.GetBool("pairing-to-curl") || viper.GetBool("realmmanagement-to-curl")
}
instead of that condition might be a better solution, though.
cmd/appengine/device.go
Outdated
@@ -571,6 +581,9 @@ func devicesDataSnapshotF(command *cobra.Command, args []string) error { | |||
if err != nil { | |||
warnOrFail(snapshotInterface, i.Name, err) | |||
} | |||
|
|||
utils.MaybeCurl(snapshotCall, astarteAPIClient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want to print the equivalent curl and run the request.
We should consider a more robust approach
cmd/realm/interfaces.go
Outdated
@@ -333,6 +349,9 @@ func getInterfaceDefinition(realm, interfaceName string, interfaceMajor int) (in | |||
return interfaces.AstarteInterface{}, err | |||
} | |||
|
|||
// don't care about `interface sync` because its flag is always false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment relevant? (check also the ones below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is relevant, but a bit too obscure. Will reword.
Add the `--to-curl` flag to print get a bash command equivalent to the one astartectl would run. If the flag is set, astartectl will take no futher action. Signed-off-by: Arnaldo Cesco <arnaldo.cesco@secomind.com>
Add the
--to-curl
flag to allow the user to get a bash command equivalent to the one astartectl would run.If the flag is set, astartectl will take no futher action.
Closes #100.