Skip to content

Conversation

@ChrisPenner
Copy link
Member

@ChrisPenner ChrisPenner commented Oct 27, 2025

Overview

Allows passing quoted args to ucm commands.

Motivated by the desire to use this for config.set-author and annotate

fixes #5417

quote-args.mp4

Implementation notes

  • Adds a custom megaparsec parser for parsing line-reader args
  • Rewrite the basic completion handler entirely to correctly respect quoted args
  • Some fixups for quoted args in history

Interesting/controversial decisions

There is a completeQuotedWord in Haskeline, but it doesn't provide the line prefix (which we need for determining the command).
Plus, writing our own parser means we can be consistent between the line parser and the completion parser.

Test coverage

Added a transcript for completion and a simple unison prog which demos quoted args to run.

Loose ends

  • Should probably skip argument expansion on quoted args so that we can finally pass numbers as arguments to run haha

I'm sure we'll find some more tweaks for this in the future, but shouldn't be hard to add those as they come up.

@ChrisPenner ChrisPenner marked this pull request as ready for review October 27, 2025 20:43
Comment on lines +237 to +241
scratch/main> debug.tab-complete "vi
view
view.global
```
Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't show in the debug output, but the actual completion will add the closing quotes, i.e. the first result would end up as "view"

Comment on lines +20 to +23
-- * Parse Arguments
parseArgs,
parseArgsQuoted,

Copy link
Member Author

Choose a reason for hiding this comment

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

I dunno the right module for these; Open to change if anyone cares 🤷🏼‍♂️

@ChrisPenner ChrisPenner requested a review from aryairani October 27, 2025 21:21
@ChrisPenner
Copy link
Member Author

ChrisPenner commented Oct 28, 2025

@aryairani I looked into preventing numbered arg expansion when quoted, I'd like to do it but it adds a bit more complexity so I think we should merge this one then I can add that in a new PR.

EDIT: here

@aryairani aryairani merged commit 2681658 into trunk Oct 29, 2025
31 checks passed
@aryairani aryairani deleted the cp/quoted-args branch October 29, 2025 03:12
@aryairani
Copy link
Contributor

@ChrisPenner I forgot to ask, how do we escape a " character?

@ChrisPenner
Copy link
Member Author

@aryairani standard backslash; "This is a quote: \""

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.

support multi-word arguments in run command

3 participants