Skip to content
This repository has been archived by the owner on May 14, 2023. It is now read-only.

Completion Command Always Returns Error #54

Merged
merged 4 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.0
0.8.1
24 changes: 14 additions & 10 deletions internal/cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,24 @@ func Completion() *cobra.Command {
func completionRunE(c *cobra.Command, args []string) error {
switch args[0] {
case "bash":
err := Root().GenBashCompletion(os.Stdout)
return fmt.Errorf("failed to generate bash completion: %w", err)
if err := Root().GenBashCompletion(os.Stdout); err != nil {
return fmt.Errorf("failed to generate bash completion: %w", err)
}
case "fish":
err := Root().GenFishCompletion(os.Stdout, true)
return fmt.Errorf("failed to generate fish completion: %w", err)
if err := Root().GenFishCompletion(os.Stdout, true); err != nil {
return fmt.Errorf("failed to generate fish completion: %w", err)
}
case "powershell":
err := Root().GenPowerShellCompletionWithDesc(os.Stdout)
return fmt.Errorf("failed to generate powershell completion: %w", err)
if err := Root().GenPowerShellCompletionWithDesc(os.Stdout); err != nil {
return fmt.Errorf("failed to generate powershell completion: %w", err)
}
case "zsh":
err := Root().GenZshCompletion(os.Stdout)
return fmt.Errorf("failed to generate zsh completion: %w", err)
default:
return nil
if err := Root().GenZshCompletion(os.Stdout); err != nil {
return fmt.Errorf("failed to generate zsh completion: %w", err)
}
}

return nil
}

func completionLong(rootName string) string {
Expand Down
1 change: 0 additions & 1 deletion internal/note/note.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func NewNote(noteSchema string) (Note, error) {
}

if errs := validate.NewFilenameValidator().Validate(note.Filename); errs != nil {
log.Info().Msgf("creating note: %s", filename)
return Note{}, fmt.Errorf("note filename validation failed: %v", errs)
}

Expand Down
10 changes: 5 additions & 5 deletions internal/validate/filename.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func NewFilenameValidator() filenameValidator { //nolint:revive

// Validate implements the validate.Validator.Valid() interface. It carries out
// a number of checks:
// - If the file extension is correct
// - Has a valid base schema (e.g. "area" from "area.language.go.error")
// - If the filename matches a combined kebab-case dot notation
// (e.g. "area.languagego.error-handling.md")
// - If the filename has the required number of parts (e.g. not "area.md").
// - If the file extension is correct
// - Has a valid base schema (e.g. "area" from "area.language.go.error")
// - If the filename matches a combined kebab-case dot notation
// (e.g. "area.languagego.error-handling.md")
// - If the filename has the required number of parts (e.g. not "area.md").
func (f filenameValidator) Validate(filename string) []error {
var errs []error

Expand Down