Skip to content

feat(abc): src abc variables command#1293

Open
bahrmichael wants to merge 20 commits intomainfrom
mb/src-abc-command
Open

feat(abc): src abc variables command#1293
bahrmichael wants to merge 20 commits intomainfrom
mb/src-abc-command

Conversation

@bahrmichael
Copy link
Copy Markdown
Contributor

@bahrmichael bahrmichael commented Apr 15, 2026

This PR introduces a src abc variables command for setting and deleting variables on workflow instances using the update variables api from Sourcegraph.

Syntax:
src abc variables delete <workflow-instance-id> <variable-name>
src abc variables set <workflow-instance-id> <variable-name>=<variable-value>

With multiple arguments and --var:
src abc variables delete <workflow-instance-id> --var <variable-name-1> --var <variable-name-2>
src abc variables set <workflow-instance-id> --var <variable-name-1>=<variable-value-1> --var <variable-name-2>=<variable-value-2>

Examples:
src abc variables delete QWdlbnRpY1dvcmtmbG93SW5zdGFuY2U6MQ== approval
src abc variables set QWdlbnRpY1dvcmtmbG93SW5zdGFuY2U6MQ== prompt="Make some follow up changes"

The workflow instance id is an argument after the delete/set command, so that we can follow the existing subcommand patterns without having to introduce support for prefix args.

Comment thread cmd/src/abc.go Outdated
Comment thread cmd/src/abc_variables.go Outdated
Comment thread cmd/src/abc_variables.go Outdated
@bahrmichael bahrmichael changed the title src abc command feat(abc): src abc variables command Apr 15, 2026
@bahrmichael bahrmichael marked this pull request as ready for review April 15, 2026 13:32
@bahrmichael bahrmichael requested a review from a team April 15, 2026 13:32
Comment thread cmd/src/abc_variables_delete.go Outdated
},
})

func parseABCVariableNames(positional []string, flagged abcVariableArgs) ([]string, error) {
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.

think we can collapse this into runABCVariablesDelete

Comment thread cmd/src/abc_variables_delete.go Outdated
return variableNames, nil
}

func runABCVariablesDelete(ctx context.Context, client api.Client, instanceID string, positional []string, flagged abcVariableArgs, output io.Writer, getCurl bool) error {
Copy link
Copy Markdown
Contributor

@burmudar burmudar Apr 16, 2026

Choose a reason for hiding this comment

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

positional and flagged can be collapsed into one array imo

Comment thread cmd/src/abc_variables_set.go Outdated

func (a *abcVariableArgs) Set(value string) error {
*a = append(*a, value)
return nil
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.

never return an error so we might as well remove it from the function signature

Comment thread cmd/src/abc_variables_set.go Outdated
return abcVariable{Key: name, Value: value}, nil
}

func runABCVariablesSet(ctx context.Context, client api.Client, instanceID string, positional []string, flagged abcVariableArgs, output io.Writer, getCurl bool) error {
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.

I think positional + flagged should be combined before this method is called

Comment thread cmd/src/abc_variables_set.go Outdated
return nil, cmderrors.Usage("must provide at least one variable assignment")
}

variables := make([]abcVariable, 0, len(rawVariables))
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.

I think you can use strings.FieldsFunc

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.

If I understand it correctly urfave should already give us individual args that don't need to be split by whitespace. For each arg (name=value) the strings.Cut method looks like a better fit to me.

Comment thread cmd/src/abc_variables_set.go Outdated
return err
}

if getCurl {
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.

I think if you're not going to support this flag then we should:

  • not pass it in
  • print a warning before running this that get-curl is currently unsupported for this command

Comment thread cmd/src/abc_variables_delete.go Outdated
}

if getCurl {
return nil
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.

see my later comment on get-curl

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