Skip to content
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

fix: Printing JSON document & printing error #145

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ func registerRHSM(ctx *cli.Context) (string, error) {
required, because user is member of more than one organization, then ask for
the organization. */
if len(orgs) > 0 {
if uiSettings.isMachineReadable {
return "Unable to register system to RHSM", cli.Exit("no organization specified", 1)
}
// Stop spinner to be able to display message and ask for organization
if uiSettings.isRich {
s.Stop()
Expand Down Expand Up @@ -245,12 +248,11 @@ func beforeConnectAction(ctx *cli.Context) error {

// When machine-readable format is used, then additional requirements have to be met
if uiSettings.isMachineReadable {
if username != "" {
if password == "" {
return fmt.Errorf("--password is required, when --username and machine-readable format are used")
}
if username == "" || password == "" {
return fmt.Errorf("--username/--password or --organization/--activation-key are required when a machine-readable format is used")
}
}

return nil
}

Expand Down Expand Up @@ -441,6 +443,8 @@ func (disconnectResult DisconnectResult) Error() string {
return err.Error()
}
result = string(data)
case "":
break
default:
result = "error: unsupported document format: " + disconnectResult.format
}
Expand Down Expand Up @@ -473,6 +477,8 @@ func (connectResult ConnectResult) Error() string {
return err.Error()
}
result = string(data)
case "":
break
default:
result = "error: unsupported document format: " + connectResult.format
}
Expand Down
Loading