diff --git a/asdf.elv b/asdf.elv index a2e016aa7..ba57cda53 100644 --- a/asdf.elv +++ b/asdf.elv @@ -150,29 +150,29 @@ fn arg-completer {|@argz| # asdf list [] ls-installed-versions $argz[-1] } elif (match $argz 'local') { - # asdf local [-p|--parent] + # asdf local [-p|--parents] asdf plugin-list put '-p' - put '--parent' - } elif (match $argz 'local' '(-p|(--parent))') { - # asdf local [-p|--parent] + put '--parents' + } elif (match $argz 'local' '(-p|(--parents))') { + # asdf local [-p|--parents] asdf plugin-list } elif (match $argz 'local' '.*') { - # asdf local [-p|--parent] + # asdf local [-p|--parents] # asdf local ls-installed-versions $argz[-1] put '-p' - put '--parent' - } elif (match $argz 'local' '(-p|(--parent))' '.*') { - # asdf local [-p|--parent] + put '--parents' + } elif (match $argz 'local' '(-p|(--parents))' '.*') { + # asdf local [-p|--parents] ls-installed-versions $argz[-1] - } elif (match $argz 'local' '.*' '(-p|(--parent))') { - # asdf local [-p|--parent] + } elif (match $argz 'local' '.*' '(-p|(--parents))') { + # asdf local [-p|--parents] ls-installed-versions $argz[-2] } elif (match $argz 'local' '.*' '.*') { - # asdf local [-p|--parent] + # asdf local [-p|--parents] put '-p' - put '--parent' + put '--parents' } elif (or (match $argz 'plugin-add') (match $argz 'plugin' 'add')) { # asdf plugin add asdf plugin-list-all | each {|line| diff --git a/docs/guide/upgrading-to-v0-16.md b/docs/guide/upgrading-to-v0-16.md index e8caee458..e62157b9a 100644 --- a/docs/guide/upgrading-to-v0-16.md +++ b/docs/guide/upgrading-to-v0-16.md @@ -153,7 +153,7 @@ terminology was wrong and also misleading. asdf doesn't actually support current directory specifying a different version. This was confusing to users. The new `asdf set` behaves the same as `asdf local` by default, but also has flags for setting versions in the user's home directory (`--home`) and in an -existing `.tool-versions` file in one of the parent directories (`--parent`). +existing `.tool-versions` file in one of the parent directories (`--parents`). This new interface will hopefully convey a better understanding of how asdf resolves versions and provide equivalent functionality. diff --git a/docs/ja-jp/guide/upgrading-to-v0-16.md b/docs/ja-jp/guide/upgrading-to-v0-16.md index 997d03b74..a52b936ce 100644 --- a/docs/ja-jp/guide/upgrading-to-v0-16.md +++ b/docs/ja-jp/guide/upgrading-to-v0-16.md @@ -78,7 +78,7 @@ asdfバージョン0.15.0およびそれ以前では、特定のコマンドの ### `asdf global` と `asdf local` コマンドが `asdf set` に変更されました -`asdf global` と `asdf local` は削除されました。「グローバル」と「ローカル」という用語は誤りで、誤解を招く恐れがありました。asdf は、実際にはあらゆる場所に適用される「グローバル」バージョンをサポートしていません。`asdf global`で指定したバージョンは、カレントディレクトリにある `.tool-versions` ファイルで簡単に上書きすることができました。これはユーザーを混乱させていました。 新しい`asdf set`はデフォルトでは`asdf local`と同じように動作しますが、ユーザーのホームディレクトリ (`--home`) や親ディレクトリ (`--parent`) にある既存の `.tool-versions` ファイルにバージョンを設定するためのフラグも用意されています。 この新しいインターフェイスは、asdfがどのようにバージョンを解決するかをよりよく理解し、同等の機能を提供することを期待しています。 +`asdf global` と `asdf local` は削除されました。「グローバル」と「ローカル」という用語は誤りで、誤解を招く恐れがありました。asdf は、実際にはあらゆる場所に適用される「グローバル」バージョンをサポートしていません。`asdf global`で指定したバージョンは、カレントディレクトリにある `.tool-versions` ファイルで簡単に上書きすることができました。これはユーザーを混乱させていました。 新しい`asdf set`はデフォルトでは`asdf local`と同じように動作しますが、ユーザーのホームディレクトリ (`--home`) や親ディレクトリ (`--parents`) にある既存の `.tool-versions` ファイルにバージョンを設定するためのフラグも用意されています。 この新しいインターフェイスは、asdfがどのようにバージョンを解決するかをよりよく理解し、同等の機能を提供することを期待しています。 ### `asdf update`コマンドが削除されました diff --git a/docs/ja-jp/manage/versions.md b/docs/ja-jp/manage/versions.md index 915d160b4..c930f2ab0 100644 --- a/docs/ja-jp/manage/versions.md +++ b/docs/ja-jp/manage/versions.md @@ -83,7 +83,7 @@ asdf set latest[:] `u` または `--home`フラグをつけて`asdf set`を実行すると、`$HOME`ディレクトリの`.tool-versions`ファイルにバージョンを書き込みます。ファイルが存在しない場合は作成されます。 -`p`または `--parent`フラグをつけて`asdf set`を実行すると、カレントディレクトリから親ディレクトリを探索し、最初に見つかった`.tool-versions` ファイルにバージョンを書き込みます。 +`p`または `--parents`フラグをつけて`asdf set`を実行すると、カレントディレクトリから親ディレクトリを探索し、最初に見つかった`.tool-versions` ファイルにバージョンを書き込みます。 #### 環境変数で管理する diff --git a/docs/manage/versions.md b/docs/manage/versions.md index eba1958b0..ce02b6bc4 100644 --- a/docs/manage/versions.md +++ b/docs/manage/versions.md @@ -86,7 +86,7 @@ just doing `echo " " > .tool-versions`. With the `-u`/`--home` flag `asdf set` writes to the `.tool-versions` file in your `$HOME` directory, creating the file if it does not exist. -With the `-p`/`--parent` flag `asdf set` finds a `.tool-versions` file in the +With the `-p`/`--parents` flag `asdf set` finds a `.tool-versions` file in the closest parent directory of the current directory. #### Via Environment Variable diff --git a/internal/cli/cli.go b/internal/cli/cli.go index e583661f7..a16bd4d80 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -277,16 +277,28 @@ func Execute(version string) { Usage: "The version should be set in the current users home directory", }, &cli.BoolFlag{ - Name: "parent", + Name: "parents", Aliases: []string{"p"}, - Usage: "The version should be set in the closest existing .tool-versions file in a parent directory", + Usage: "The version should be set in the closest existing .tool-versions file in a parent directory.", + }, + &cli.BoolFlag{ + Name: "parent", + Hidden: false, + Usage: "Has been renamed to --parents. See above.", }, }, Action: func(_ context.Context, cmd *cli.Command) error { args := cmd.Args().Slice() home := cmd.Bool("home") + parents := cmd.Bool("parents") parent := cmd.Bool("parent") - return set.Main(os.Stdout, os.Stderr, args, home, parent, func() (string, error) { + + if parent { + const msg = "Warning: set --parent has been renamed to --parents. Please use --parents instead." + logger.Println(msg) + } + + return set.Main(os.Stdout, os.Stderr, args, home, parents || parent, func() (string, error) { return os.UserHomeDir() }) }, diff --git a/internal/cli/set/set.go b/internal/cli/set/set.go index 407872e81..d97142bee 100644 --- a/internal/cli/set/set.go +++ b/internal/cli/set/set.go @@ -16,7 +16,7 @@ import ( ) // Main function is the entrypoint for the 'asdf set' command -func Main(_ io.Writer, stderr io.Writer, args []string, home bool, parent bool, homeFunc func() (string, error)) error { +func Main(_ io.Writer, stderr io.Writer, args []string, home bool, parents bool, homeFunc func() (string, error)) error { if len(args) < 1 { return printError(stderr, "tool and version must be provided as arguments") } @@ -25,8 +25,8 @@ func Main(_ io.Writer, stderr io.Writer, args []string, home bool, parent bool, return printError(stderr, "version must be provided as an argument") } - if home && parent { - return printError(stderr, "home and parent flags cannot both be specified; must be one location or the other") + if home && parents { + return printError(stderr, "home and parents flags cannot both be specified; must be one location or the other") } conf, err := config.LoadConfig() @@ -71,11 +71,11 @@ func Main(_ io.Writer, stderr io.Writer, args []string, home bool, parent bool, return printError(stderr, fmt.Sprintf("unable to get current directory: %s", err)) } - if parent { - // locate file in parent dir and update it - path, found := findVersionFileInParentDir(conf, currentDir) + if parents { + // locate file in parents dir and update it + path, found := findVersionFileInParentDirs(conf, currentDir) if !found { - return printError(stderr, fmt.Sprintf("No %s version file found in parent directory", conf.DefaultToolVersionsFilename)) + return printError(stderr, fmt.Sprintf("No %s version file found in parent directories", conf.DefaultToolVersionsFilename)) } err = toolversions.WriteToolVersionsToFile(path, []toolversions.ToolVersions{tv}) @@ -98,7 +98,7 @@ func printError(stderr io.Writer, msg string) error { return errors.New(strings.TrimSuffix(msg, "\n")) } -func findVersionFileInParentDir(conf config.Config, directory string) (string, bool) { +func findVersionFileInParentDirs(conf config.Config, directory string) (string, bool) { directory = filepath.Dir(directory) for { diff --git a/internal/cli/set/set_test.go b/internal/cli/set/set_test.go index 8f48d2b83..dc3d48be1 100644 --- a/internal/cli/set/set_test.go +++ b/internal/cli/set/set_test.go @@ -32,13 +32,13 @@ func TestAll(t *testing.T) { assert.Equal(t, stderr.String(), "version must be provided as an argument\n") }) - t.Run("prints error when both --parent and --home flags are set", func(t *testing.T) { + t.Run("prints error when both --parents and --home flags are set", func(t *testing.T) { stdout, stderr := buildOutputs() err := Main(&stdout, &stderr, []string{"lua", "5.2.3"}, true, true, homeFunc) - assert.Error(t, err, "home and parent flags cannot both be specified; must be one location or the other") + assert.Error(t, err, "home and parents flags cannot both be specified; must be one location or the other") assert.Equal(t, stdout.String(), "") - assert.Equal(t, stderr.String(), "home and parent flags cannot both be specified; must be one location or the other\n") + assert.Equal(t, stderr.String(), "home and parents flags cannot both be specified; must be one location or the other\n") }) t.Run("sets version in current directory when no flags provided", func(t *testing.T) { @@ -58,7 +58,7 @@ func TestAll(t *testing.T) { assert.Equal(t, "lua 5.2.3\n", string(bytes)) }) - t.Run("sets version in parent directory when --parent flag provided", func(t *testing.T) { + t.Run("sets version in parents directory when --parents flag provided", func(t *testing.T) { stdout, stderr := buildOutputs() dir := t.TempDir() subdir := filepath.Join(dir, "subdir") diff --git a/internal/completions/asdf.elvish b/internal/completions/asdf.elvish index e145ad283..04643b733 100644 --- a/internal/completions/asdf.elvish +++ b/internal/completions/asdf.elvish @@ -55,29 +55,29 @@ fn arg-completer {|@argz| # asdf list [] ls-installed-versions $argz[-1] } elif (match $argz 'local') { - # asdf local [-p|--parent] + # asdf local [-p|--parents] asdf plugin-list put '-p' - put '--parent' - } elif (match $argz 'local' '(-p|(--parent))') { - # asdf local [-p|--parent] + put '--parents' + } elif (match $argz 'local' '(-p|(--parents))') { + # asdf local [-p|--parents] asdf plugin-list } elif (match $argz 'local' '.*') { - # asdf local [-p|--parent] + # asdf local [-p|--parents] # asdf local ls-installed-versions $argz[-1] put '-p' - put '--parent' - } elif (match $argz 'local' '(-p|(--parent))' '.*') { - # asdf local [-p|--parent] + put '--parents' + } elif (match $argz 'local' '(-p|(--parents))' '.*') { + # asdf local [-p|--parents] ls-installed-versions $argz[-1] - } elif (match $argz 'local' '.*' '(-p|(--parent))') { - # asdf local [-p|--parent] + } elif (match $argz 'local' '.*' '(-p|(--parents))') { + # asdf local [-p|--parents] ls-installed-versions $argz[-2] } elif (match $argz 'local' '.*' '.*') { - # asdf local [-p|--parent] + # asdf local [-p|--parents] put '-p' - put '--parent' + put '--parents' } elif (or (match $argz 'plugin-add') (match $argz 'plugin' 'add')) { # asdf plugin add asdf plugin-list-all | each {|line| diff --git a/internal/completions/asdf.fish b/internal/completions/asdf.fish index 70afc097b..d7f65f603 100644 --- a/internal/completions/asdf.fish +++ b/internal/completions/asdf.fish @@ -128,7 +128,7 @@ complete -f -c asdf -n '__fish_asdf_using_command set; and test (count (commandl # set commands complete -f -c asdf -n '__fish_asdf_using_command set' -l home -d "Set version in home directory" -complete -f -c asdf -n '__fish_asdf_using_command set' -l parent -d "Set version in parent directory" +complete -f -c asdf -n '__fish_asdf_using_command set' -l parents -d "Set version in closest parent directory" # misc complete -f -c asdf -n __fish_asdf_needs_command -l help -d "Displays help" diff --git a/internal/help/help.txt b/internal/help/help.txt index e4b3b86b0..0736a2c6d 100644 --- a/internal/help/help.txt +++ b/internal/help/help.txt @@ -36,8 +36,8 @@ asdf list [version] List installed versions of a package and asdf list all [] List all versions of a package and optionally filter the returned versions asdf set [-u] [-p] Set a tool version in a .tool-version in - the current directory, or a parent - directory. + the current directory, or the closest + parent directory. asdf uninstall Remove a specific version of a package asdf where [] Display install path for an installed or current version diff --git a/internal/resolve/resolve_test.go b/internal/resolve/resolve_test.go index d4a51f897..fae2146dc 100644 --- a/internal/resolve/resolve_test.go +++ b/internal/resolve/resolve_test.go @@ -56,7 +56,7 @@ func TestVersion(t *testing.T) { assert.Equal(t, toolVersion.Versions, []string{"2.3.4"}) }) - t.Run("returns single version from .tool-versions file in parent directory", func(t *testing.T) { + t.Run("returns single version from .tool-versions file in closest parent directory", func(t *testing.T) { // write a version file data := []byte(fmt.Sprintf("%s 1.2.3", testPluginName)) err = os.WriteFile(filepath.Join(currentDir, ".tool-versions"), data, 0o666) diff --git a/lib/functions/versions.bash b/lib/functions/versions.bash index 7d1d941d6..1ac868fb0 100644 --- a/lib/functions/versions.bash +++ b/lib/functions/versions.bash @@ -214,13 +214,13 @@ latest_all() { } local_command() { - local parent=false + local parents=false local positional=() while [[ $# -gt 0 ]]; do case $1 in - -p | --parent) - parent="true" + -p | --parents) + parents="true" shift # past value ;; *) @@ -232,7 +232,7 @@ local_command() { set -- "${positional[@]}" # restore positional parameters - if [ $parent = true ]; then + if [ $parents = true ]; then version_command local-tree "$@" else version_command local "$@" diff --git a/scripts/checkstyle.py b/scripts/checkstyle.py index 28294ea0b..d065d755e 100755 --- a/scripts/checkstyle.py +++ b/scripts/checkstyle.py @@ -254,6 +254,9 @@ def main(): for file in Path.cwd().glob('**/*'): if '.git' in str(file.absolute()): continue + + if file.name == '.DS_Store': + continue if file.is_file(): lintfile(file, rules, options) diff --git a/scripts/lint.bash b/scripts/lint.bash index 3553d60e1..8f5a6e2b6 100755 --- a/scripts/lint.bash +++ b/scripts/lint.bash @@ -91,6 +91,8 @@ run_custom_python_stylecheck() { printf "%s\n" "[WARNING] python3 not found. Skipping Custom Python Script." else print.info "Checking files with Custom Python Script." + print.info "${flag}" + print.info "${0%/*}/checkstyle.py" "${0%/*}/checkstyle.py" "${flag}" fi diff --git a/test/install_command.bats b/test/install_command.bats index 2b78aa3c1..e1173a518 100644 --- a/test/install_command.bats +++ b/test/install_command.bats @@ -190,7 +190,7 @@ EOM [ ! -f "$ASDF_DIR/installs/other-dummy/2.0.0/version" ] } -@test "install_command without arguments uses a parent directory .tool-versions file if present" { +@test "install_command without arguments uses the closest parent directory .tool-versions file if present" { # asdf lib needed to run generated shims cp -rf "$BATS_TEST_DIRNAME"/../{bin,lib} "$ASDF_DIR/" diff --git a/test/utils.bats b/test/utils.bats index ed84ca249..ca432e670 100644 --- a/test/utils.bats +++ b/test/utils.bats @@ -338,7 +338,7 @@ teardown() { [ "$output" = "$PROJECT_DIR/.tool-versions" ] } -@test "find_tool_versions will find a .tool-versions path if it exists in parent directory" { +@test "find_tool_versions will find a .tool-versions path if it exists in any parent directory" { echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions" mkdir -p "$PROJECT_DIR/child" cd "$PROJECT_DIR"/child diff --git a/test/version_commands.bats b/test/version_commands.bats index 81a4f91b8..c841e2dcb 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -156,25 +156,25 @@ teardown() { [ "$(cat "$PROJECT_DIR/.tool-versions")" = "dummy path:$PROJECT_DIR/local" ] } -@test "local -p/--parent should set should emit an error when called with incorrect arity" { +@test "local -p/--parents should set should emit an error when called with incorrect arity" { run asdf local -p "dummy" [ "$status" -eq 1 ] [ "$output" = "Usage: asdf local " ] } -@test "local -p/--parent should emit an error when plugin does not exist" { +@test "local -p/--parents should emit an error when plugin does not exist" { run asdf local -p "inexistent" "1.0.0" [ "$status" -eq 1 ] [ "$output" = "No such plugin: inexistent" ] } -@test "local -p/--parent should emit an error when plugin version does not exist" { +@test "local -p/--parents should emit an error when plugin version does not exist" { run asdf local -p "dummy" "0.0.1" [ "$status" -eq 1 ] [ "$output" = "version 0.0.1 is not installed for dummy" ] } -@test "local -p/--parent should allow multiple versions" { +@test "local -p/--parents should allow multiple versions" { cd "$CHILD_DIR" touch "$PROJECT_DIR/.tool-versions" run asdf local -p "dummy" "1.1.0" "1.0.0" @@ -182,7 +182,7 @@ teardown() { [ "$(cat "$PROJECT_DIR/.tool-versions")" = "dummy 1.1.0 1.0.0" ] } -@test "local -p/--parent should overwrite the existing version if it's set" { +@test "local -p/--parents should overwrite the existing version if it's set" { cd "$CHILD_DIR" echo 'dummy 1.0.0' >>"$PROJECT_DIR/.tool-versions" run asdf local -p "dummy" "1.1.0" @@ -190,7 +190,7 @@ teardown() { [ "$(cat "$PROJECT_DIR/.tool-versions")" = "dummy 1.1.0" ] } -@test "local -p/--parent should set the version if it's unset" { +@test "local -p/--parents should set the version if it's unset" { cd "$CHILD_DIR" touch "$PROJECT_DIR/.tool-versions" run asdf local -p "dummy" "1.1.0"