Skip to content

Commit 403dce5

Browse files
committed
Requested
1 parent 7c99803 commit 403dce5

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

internal/autodetect/autodetect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func relevantDetector(path string) (detector.Detector, error) {
6262
relevantScore := 0.0
6363
var mostRelevantDetector detector.Detector
6464
for _, detector := range detectors(path) {
65-
score, err := detector.IsRelevant(path)
65+
score, err := detector.Relevance(path)
6666
if err != nil {
6767
return nil, err
6868
}

internal/autodetect/detector/detector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package detector
33
import "context"
44

55
type Detector interface {
6-
IsRelevant(path string) (float64, error)
6+
Relevance(path string) (float64, error)
77
Packages(ctx context.Context) ([]string, error)
88
}

internal/autodetect/detector/poetry.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ type PoetryDetector struct {
1616
Root string
1717
}
1818

19-
func (d *PoetryDetector) IsRelevant(path string) (float64, error) {
19+
var _ Detector = &PoetryDetector{}
20+
21+
func (d *PoetryDetector) Relevance(path string) (float64, error) {
2022
pyprojectPath := filepath.Join(d.Root, "pyproject.toml")
2123
_, err := os.Stat(pyprojectPath)
2224
if err == nil {

internal/autodetect/detector/python.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ type PythonDetector struct {
1010
Root string
1111
}
1212

13-
func (d *PythonDetector) IsRelevant(path string) (float64, error) {
13+
var _ Detector = &PythonDetector{}
14+
15+
func (d *PythonDetector) Relevance(path string) (float64, error) {
1416
requirementsPath := filepath.Join(d.Root, "requirements.txt")
1517
_, err := os.Stat(requirementsPath)
1618
if err == nil {

internal/boxcli/init.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
)
1313

1414
type initFlags struct {
15-
autoDetect bool
16-
dryRun bool
15+
auto bool
16+
dryRun bool
1717
}
1818

1919
func initCmd() *cobra.Command {
@@ -30,17 +30,18 @@ func initCmd() *cobra.Command {
3030
},
3131
}
3232

33-
command.Flags().BoolVar(&flags.autoDetect, "autodetect", false, "Automatically detect packages to add")
33+
command.Flags().BoolVar(&flags.auto, "auto", false, "Automatically detect packages to add")
3434
command.Flags().BoolVar(&flags.dryRun, "dry-run", false, "Dry run")
35-
command.Flag("autodetect").Hidden = true
35+
_ = command.Flags().MarkHidden("auto")
36+
_ = command.Flags().MarkHidden("dry-run")
3637

3738
return command
3839
}
3940

4041
func runInitCmd(cmd *cobra.Command, args []string, flags *initFlags) error {
4142
path := pathArg(args)
4243

43-
if flags.autoDetect && flags.dryRun {
44+
if flags.auto && flags.dryRun {
4445
return autodetect.DryRun(cmd.Context(), path, cmd.ErrOrStderr())
4546
}
4647

@@ -49,7 +50,7 @@ func runInitCmd(cmd *cobra.Command, args []string, flags *initFlags) error {
4950
return errors.WithStack(err)
5051
}
5152

52-
if flags.autoDetect {
53+
if flags.auto {
5354
err = autodetect.PopulateConfig(cmd.Context(), path, cmd.ErrOrStderr())
5455
}
5556

0 commit comments

Comments
 (0)