Skip to content

Commit

Permalink
Revert "Allow file-based completion for various arguments (#3202)" (#…
Browse files Browse the repository at this point in the history
…3231)

* Revert "Allow file-based completion for various arguments (#3202)"

This reverts commit bdf18bb.

* update the blasted docs again

* Update version
  • Loading branch information
peterebden authored Aug 20, 2024
1 parent 8183415 commit 9625bae
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.10.1
17.10.2
4 changes: 2 additions & 2 deletions docs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 3 additions & 8 deletions src/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions src/help/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions src/please.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 != "" {
Expand Down

0 comments on commit 9625bae

Please sign in to comment.