From 9625baec42236b95c9f8cdccad2c81277505d0cd Mon Sep 17 00:00:00 2001 From: Peter Ebden Date: Tue, 20 Aug 2024 14:39:05 +0100 Subject: [PATCH] Revert "Allow file-based completion for various arguments (#3202)" (#3231) * Revert "Allow file-based completion for various arguments (#3202)" This reverts commit bdf18bb488e232de3899084e8b46f2c28f846a73. * update the blasted docs again * Update version --- ChangeLog | 4 ++++ VERSION | 2 +- docs/BUILD | 4 ++-- src/cli/flags.go | 11 +++-------- src/help/rules.go | 5 +++-- src/please.go | 16 ++++++++-------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3c999ead6..4be7e9efb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Version 17.10.2 +--------------- + * Revert change to filename auto-completion from 17.10.0 (#3229) + Version 17.10.1 --------------- * Improve internal comparison of subrepo structures, resolving a "found multiple definitions for diff --git a/VERSION b/VERSION index 60d8373f80..8eaf1554c7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -17.10.1 +17.10.2 diff --git a/docs/BUILD b/docs/BUILD index ea493fbab6..d941af9229 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -58,8 +58,8 @@ genrule( # Plugin versions to pull the docs from plugins = { "python": "v1.7.0", - "java": "v0.4.0", - "go": "v1.20.1", + "java": "v0.4.1", + "go": "v1.21.1", "cc": "v0.4.0", "shell": "v0.2.0", "go-proto": "v0.3.0", diff --git a/src/cli/flags.go b/src/cli/flags.go index 7392279c38..7c0e02c890 100644 --- a/src/cli/flags.go +++ b/src/cli/flags.go @@ -212,15 +212,10 @@ func (f *Filepath) Complete(match string) []flags.Completion { type Filepaths []Filepath // AsStrings returns this slice of filepaths as a slice of strings. -// It understands the - character to mean reading input from stdin. func (f Filepaths) AsStrings() []string { - ret := make([]string, 0, len(f)) - for _, fp := range f { - if fp == "-" { - ret = append(ret, cli.ReadAllStdin()...) - } else { - ret = append(ret, string(fp)) - } + ret := make([]string, len(f)) + for i, fp := range f { + ret[i] = string(fp) } return ret } diff --git a/src/help/rules.go b/src/help/rules.go index bb5f7e5243..c3f5d79505 100644 --- a/src/help/rules.go +++ b/src/help/rules.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/thought-machine/please/rules" + "github.com/thought-machine/please/src/cli" "github.com/thought-machine/please/src/cli/logging" "github.com/thought-machine/please/src/core" "github.com/thought-machine/please/src/fs" @@ -21,7 +22,7 @@ var log = logging.Log // // a) all builtin rules if no files are passed, or // b) all rules in the given files. -func PrintRuleArgs(files []string) { +func PrintRuleArgs(files cli.StdinStrings) { var funcMap map[string]*asp.Statement if len(files) > 0 { log.Debugf("Got some files") @@ -118,7 +119,7 @@ func getFunctionsFromState(state *core.BuildState) map[string]*asp.Statement { return AllBuiltinFunctions(state) } -func getFunctionsFromFiles(files []string) map[string]*asp.Statement { +func getFunctionsFromFiles(files cli.StdinStrings) map[string]*asp.Statement { state := newState() p := asp.NewParser(state) return parseFilesForFunctions(p, files) diff --git a/src/please.go b/src/please.go index 85a52b8386..870ee8d4c7 100644 --- a/src/please.go +++ b/src/please.go @@ -411,18 +411,18 @@ var opts struct { EchoFiles bool `long:"echo_files" description:"Echo the file for which the printed output is responsible."` IgnoreUnknown bool `long:"ignore_unknown" description:"Ignore any files that are not inputs to existing build targets"` Args struct { - Files cli.Filepaths `positional-arg-name:"files" description:"Files to query as sources to targets" required:"true"` + Files cli.StdinStrings `positional-arg-name:"files" description:"Files to query as sources to targets" required:"true"` } `positional-args:"true" required:"true"` } `command:"whatinputs" description:"Prints out target(s) with provided file(s) as inputs"` WhatOutputs struct { EchoFiles bool `long:"echo_files" description:"Echo the file for which the printed output is responsible."` Args struct { - Files cli.Filepaths `positional-arg-name:"files" required:"true" description:"Files to query targets responsible for"` + Files cli.StdinStrings `positional-arg-name:"files" required:"true" description:"Files to query targets responsible for"` } `positional-args:"true"` } `command:"whatoutputs" description:"Prints out target(s) responsible for outputting provided file(s)"` Rules struct { Args struct { - Files cli.Filepaths `positional-arg-name:"files" description:"Files to parse for build rules." hidden:"true"` + Files cli.StdinStrings `positional-arg-name:"files" description:"Files to parse for build rules." hidden:"true"` } `positional-args:"true"` } `command:"rules" description:"Prints built-in rules to stdout as JSON"` Changes struct { @@ -433,7 +433,7 @@ var opts struct { Inexact bool `long:"inexact" description:"Calculate changes more quickly and without doing any SCM checkouts, but may miss some targets."` In string `long:"in" description:"Calculate changes contained within given scm spec (commit range/sha/ref/etc). Implies --inexact."` Args struct { - Files cli.Filepaths `positional-arg-name:"files" description:"Files to calculate changes for. Overrides flags relating to SCM operations."` + Files cli.StdinStrings `positional-arg-name:"files" description:"Files to calculate changes for. Overrides flags relating to SCM operations."` } `positional-args:"true"` } `command:"changes" description:"Calculates the set of changed targets in regard to a set of modified files or SCM commits."` Filter struct { @@ -868,7 +868,7 @@ var buildFunctions = map[string]func() int{ }) }, "query.whatinputs": func() int { - files := opts.Query.WhatInputs.Args.Files.AsStrings() + files := opts.Query.WhatInputs.Args.Files.Get() // Make all these relative to the repo root; many things do not work if they're absolute. for i, file := range files { if filepath.IsAbs(file) { @@ -893,11 +893,11 @@ var buildFunctions = map[string]func() int{ }, "query.whatoutputs": func() int { return runQuery(true, core.WholeGraph, func(state *core.BuildState) { - query.WhatOutputs(state.Graph, opts.Query.WhatOutputs.Args.Files.AsStrings(), opts.Query.WhatOutputs.EchoFiles) + query.WhatOutputs(state.Graph, opts.Query.WhatOutputs.Args.Files.Get(), opts.Query.WhatOutputs.EchoFiles) }) }, "query.rules": func() int { - help.PrintRuleArgs(opts.Query.Rules.Args.Files.AsStrings()) + help.PrintRuleArgs(opts.Query.Rules.Args.Files) return 0 }, "query.changes": func() int { @@ -930,7 +930,7 @@ var buildFunctions = map[string]func() int{ }) } if len(opts.Query.Changes.Args.Files) > 0 { - return runInexact(opts.Query.Changes.Args.Files.AsStrings()) + return runInexact(opts.Query.Changes.Args.Files.Get()) } scm := scm.MustNew(core.RepoRoot) if opts.Query.Changes.In != "" {