-
Notifications
You must be signed in to change notification settings - Fork 36
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
Make argument and flag use consistent across commands #343
Comments
I'm not aware of any required args that are currently positional. Adding to 1.0.0 milestone because it's such a large change. So this current command:
with workflow ID, reason, and either event id or type required might become:
|
@lorensr Possibly yeah. If a command has lots of required arguments (e.g. more than 2 or maaaaybe 3), I'd want to evaluate more closely whether going positional is actually a good idea, so it's not a given that this will change everywhere. But I think it would be good to change where it makes sense / is more ergonomic—that's the primary concern. Opinions welcome. :) |
Note, the poor library we use for CLI won't be able to extract positional args if a flag arg is after it I don't believe. We made a huge mistake not going with cobra, and I suspect this is a consequence of that too. See temporalio/documentation#2345. |
I agree we should have gone with Cobra, we inherited this problem when the project was ported from "tctl v2". |
Also see #347 |
Here are three options for us to consider, in order of my preference: Option 1 (preferred): Use positional arguments for direct objectsWe change our arguments/flags to follow two principles:
Specifically, I propose we make the following changes:
No changes are proposed to the other subcommands ( For Here are a couple contrived but real-world-shaped examples (I pulled these from my own shell history when playing around with toy workflows): Executing a workflow:
Describing a workflow:
( If we decide to go forward with this, we can have a transition period where both the old and new forms are accepted (with a warning) before removing the old forms, to allow users time to update their scripts. Option 2 (alternative): Make everything use flagsIf we choose not to go forward with option 1, we can get rid of positional arguments entirely, and at minimum do another pass at the flags to make sure they are consistent between commands (e.g. This would mainly affect the
Option 3: Do nothingWe could also decide to keep commands, flags and arguments as-is, because changing them isn't worth the cost of breaking backward compatibility. This is my least-favorite option because we have an opportunity to polish things now that we won't post-GA (when backward compatibility becomes mandatory). |
@josh-berry I like this proposal: I agree that we should at least consider bringing the interface in line with Unix CLI tradition in the way you're suggesting. I'm imagining your idea looking something like
So, positionals are typically meaningful names. I'm thinking that opaque identifiers (e.g. workflow ID, activity ID) should never be positionals: so we'd always use |
(FYI for anyone following along both inside and outside of Temporal: I'd like to make a decision on this in the next few days, so we can move forward with whatever changes are needed, if any.) |
I vote option 2 or 3. Reasons:
Overall, taking into account past and future use, I think we would be hurting users more than helping by making this unnecessary change. |
Notes from team discussion:
|
Can you clarify the opposition to option 3? Are we trying to be so consistent between |
@cretz A couple folks in the meeting mentioned confusion around how Ultimately it's quite subjective which things make sense as positionals and which don't. Just in the course of this discussion, we've had different folks proposing different approaches (e.g. my option 1, Dan's mod to option 1, your desire to keep things the same) and none of the options are obviously more intuitive than the others. That leads me to think that eliminating them entirely strikes the right balance between minimizing churn for our existing users and maximizing consistency and ease-of-understanding for new users. |
I don't think there ever was a consistency and ease-of-understanding issue with We can't yet count future issues this will cause, but we can count past issues we've had with confusion on I believe this will now be our largest compatibility break to date on the CLI. I hope all the benefits are worth it. |
Option 2 - specific changes proposed:
I think I have a stronger opinion about fixing the inconsistencies than I do about |
Discussed in our team meeting and decided to adopt option 2 with a deprecation period for all breaking changes. So we will accept both old and new forms for a while, warn on the old forms being used, and then eventually the old forms will stop working. We can figure out the exact details of deprecation later, but for now, we should at minimum print a warning to stderr. |
Sorry for late comments: I do find the Option 1½: Accept all the current flags, but also:
That would be enough to make me happy, since those are the most commonly used interactive commands and the most obvious "direct objects". (I have no opinions on |
I fear that multiple ways to express the same thing is unnecessarily confusing/ambiguous to solve this "problem" (which I'd argue isn't really a "problem" today, we just kinda told ourselves it was). |
I'm not making anything up, I'm saying this has annoyed me in the past when using the cli to debug issues on cloud, and I believe I would be able to work (slightly) faster if I could leave out the -w and -r and -t and -s in these unambiguous situations. I don't know if it rises to the level of "problem", obviously it's not a huge deal. Yes, multiple ways to say the same thing are potentially confusing. But it's a common thing to do in shells and clis because it also improves efficiency of using them. That's why shells have a much "looser" syntax than proper programming languages, and why we still use them for interactive use instead of "better" options. They're allowed to be a little more like natural language. |
I ran into this with In the shorter commands with no arguments you can put it at the end and it works: # works
temporal workflow list --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" But e.g. # works
temporal operator namespace create --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" mynewnamespace
# none of these work
temporal --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" operator namespace create mynewnamespace
temporal operator --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" namespace create mynewnamespace
temporal operator namespace --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" create mynewnamespace
temporal operator namespace create mynewnamespace --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" Or # works
temporal env set --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" local.x-a 1
# none of these work
temporal --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" local.x-a env set 1
temporal env --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" set local.x-a 1
temporal env set local.x-a --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" 1
temporal env set local.x-a 1 --grpc-meta "Authorization=Bearer $TEMPORAL_TOKEN" |
FWIW, the upcoming RC release will solve two of these issues: 1) there will not be a required flag order, and 2) there is an |
That is great news! assuming it works for those of us not on Temporal cloud :D |
@metavee - it will, it just is a shortcut for setting the header manually. |
Wonderful, thank you |
I'm realizing we have a small problem with I am also going to drop the changes for |
Closes #343. See the issue for the full discussion and rationale behind the specific changes made.
Closes #343. See the issue for the full discussion and rationale behind the specific changes made.
Not a problem if we don't make new unnecessary aliases |
Closes #343. See the issue for the full discussion and rationale behind the specific changes made. --------- Co-authored-by: Chad Retz <chad@temporal.io>
Some commands have required flags—we should take a pass at every command and see if there are required flags that should instead be positional arguments.
Exceptions might be situations where it's not obvious which order arguments should be provided in, or what the arguments actually are when reading a particular CLI invocation (since script writers will probably appreciate having named flags for documentation purposes).
The text was updated successfully, but these errors were encountered: