Skip to content

Commit

Permalink
Merge branch 'floitsch/45.cache-env' into floitsch/50.config
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch committed Nov 17, 2023
2 parents de5b34d + ad6be51 commit 60c1ed6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
7 changes: 5 additions & 2 deletions package.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
sdk: ^2.0.0-alpha.100
sdk: ^2.0.0-alpha.120
prefixes:
fs: pkg-fs
host: pkg-host
packages:
pkg-fs:
path: ../pkg-fs
url: github.com/toitlang/pkg-fs
name: fs
version: 1.0.0
hash: c816c85022a155f37a4396455da9b27595050de1
prefixes:
host: pkg-host
pkg-host:
Expand Down
3 changes: 2 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ environment:
sdk: ^2.0.0-alpha.100
dependencies:
fs:
path: ../pkg-fs
url: github.com/toitlang/pkg-fs
version: ^1.0.0
host:
url: github.com/toitlang/pkg-host
version: ^1.11.0
7 changes: 3 additions & 4 deletions src/cache.toit
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ class Cache:
*/
constructor --app-name/string:
app-name-upper := app-name.to-ascii-upper
env := os.env
if env.contains "$(app-name-upper)_CACHE_DIR":
path := env["$(app-name-upper)_CACHE_DIR"]
return Cache --app-name=app-name --path=path
env-path := os.env.get "$(app-name-upper)_CACHE_DIR"
if env-path:
return Cache --app-name=app-name --path=env-path

cache-home := xdg.cache-home
return Cache --app-name=app-name --path="$cache-home/$(app-name)"
Expand Down
3 changes: 1 addition & 2 deletions src/cli.toit
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ abstract class Option:
if short-name and not is-alpha-num-string_ short-name:
throw "Invalid short option name: '$short-name'"
if split-commas and not multi:
throw "--split_commas is only valid for multi options."
throw "--split-commas is only valid for multi options."
if is-hidden and is-required:
throw "Option can't be hidden and required."

Expand Down Expand Up @@ -655,7 +655,6 @@ class OptionPatterns extends Option:
key: str[separator-index + 1..]
}


/**
A Uuid option.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/options_test.toit
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ test-flag:
flag.parse "foo"

test-bad-combos:
expect-throw "--split_commas is only valid for multi options.":
expect-throw "--split-commas is only valid for multi options.":
cli.Option "foo" --split-commas

expect-throw "Invalid short option name: '@'":
Expand Down
7 changes: 5 additions & 2 deletions tests/package.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sdk: ^2.0.0-alpha.64
sdk: ^2.0.0-alpha.120
prefixes:
cli: ..
host: pkg-host
Expand All @@ -9,7 +9,10 @@ packages:
fs: pkg-fs
host: pkg-host
pkg-fs:
path: ../../pkg-fs
url: github.com/toitlang/pkg-fs
name: fs
version: 1.0.0
hash: c816c85022a155f37a4396455da9b27595050de1
prefixes:
host: pkg-host
pkg-host:
Expand Down

0 comments on commit 60c1ed6

Please sign in to comment.