Skip to content

Conversation

@vito
Copy link
Owner

@vito vito commented Apr 17, 2022

Inputs can be passed as key-value pairs fed as JSON on *stdin*. Paths are parsed into host paths, which must start with ./ or / regardless of your local platform's slash preferences.

$ ./build -i src=./ -i os=linux
(next *stdin*) ; => {:src <host: ./> :os "linux"}

This approach should let us get pretty far without having to implement full-blown flag parsing where we'd also have to figure out how to represent rich objects like thunk paths in someplace that only takes strings. Here we can just encode them as JSON.

I think passing objects on stdin is generally preferable to flags/argv in an automation scenario, but it sucks for interactive use (no one wants to type JSON), hence --input/-i for passing values instead. This approach maximizes reusability of scripts between interactive dev shells, CI hooks, and/or being called from other Bass scripts:

(run (*dir*/build {:src src :os "linux"}))

Someday we could support omitting the braces for keyword arg like UX.

vito added 3 commits April 16, 2022 20:23
automatically parses paths (path style, not filepath) and turns them
into HostPaths.

use case: writing bass scripts which take params on stdin.

  ./bass/build -i src=./ -i os=darwin

will end up with this value being returned by `(next *stdin*)`:

  {:src <host: .> :os "darwin"}

...once I fix reading JSON encoded host paths, anyway.
this should keep complex values like thunk paths and host paths from
denormalizing into scopes when marshaled and unmarshaled from JSON.
+ add 'Raw' for decoding/unmarshaling without Descoping
+ fix a theoretical issue with doing a raw json.Unmarshal into a
  ThunkPath
+ move Descope to json.go, slightly better fit
@vito vito added the enhancement New feature or request label Apr 17, 2022
@vito vito merged commit 2f43aee into main Apr 17, 2022
@vito vito deleted the inputs branch April 17, 2022 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants