Skip to content

Key/Value data from CLI#2894

Merged
laurmaedje merged 13 commits intotypst:mainfrom
C0ffeeCode:sys-inputs
Dec 18, 2023
Merged

Key/Value data from CLI#2894
laurmaedje merged 13 commits intotypst:mainfrom
C0ffeeCode:sys-inputs

Conversation

@C0ffeeCode
Copy link
Contributor

@C0ffeeCode C0ffeeCode commented Dec 9, 2023

Fixes #295
Closes #2481

Differences to #2481

This is a rebase of #2481 with its feedback applied.
The --input-json CLI flag is removed since it functionality can be achieved more flexible otherwise (e.g. #json.decode(sys.inputs.SOME_KEY)).

Currently, it is not handled when a key is given more once, the last assignment stays.

This PR also adds the --pipe-input some_key flag, which allows to read one string to make available under the specified key.

Usage

specify CLI flags like --input SOME_KEY=some-value.
These are then available as sys.inputs.
For parsing data to a specific format, it can be parsed using e.g. #json.decode(sys.inputs.SOME_KEY) or other formats.

Copy link
Contributor

@tingerrr tingerrr left a comment

Choose a reason for hiding this comment

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

Only accepting strings is probably the most reasonable approach. But I'm wondering if we want to allow at least some other built in types too.

But maybe that's unecessary.

@laurmaedje
Copy link
Member

laurmaedje commented Dec 12, 2023

I think it should always be strings and the conversion should be done in Typst code. Otherwise, it gets confusing like YAML where you don't know whether 10 is an int or a string.

@C0ffeeCode
Copy link
Contributor Author

I was thinking if (and if, how) to take input from a pipe.
That could make scripting easier as well.

- move "sys.rs" back to foundations
- Remove `InputPairError`
- Renames `SystemWorld`'s `input` to `source`
@laurmaedje
Copy link
Member

I was thinking if (and if, how) to take input from a pipe.

I hadn't seen that comment earlier.

I'm not convinced that this is useful enough to warrant the complexity. It seems out of scope. Even if we discuss it further, I'd prefer to not have it as part of this initial PR.

@laurmaedje laurmaedje merged commit 22ba682 into typst:main Dec 18, 2023
@laurmaedje
Copy link
Member

Thank you!

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.

Placeholders / parameters via CLI

4 participants