satisfy linter

This commit is contained in:
2026-08-31 22:02:07 +02:00
parent cafc65aea7
commit 49eb1033ef
23 changed files with 327 additions and 220 deletions

View File

@@ -1,3 +1,5 @@
package cmd
/*
Copyright © 2024 Thomas von Dein
@@ -14,7 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cmd
import (
"bytes"
@@ -25,11 +26,11 @@ import (
"os"
"os/exec"
"github.com/spf13/cobra"
"codeberg.org/scip/anydb/app"
"codeberg.org/scip/anydb/cfg"
"codeberg.org/scip/anydb/output"
"codeberg.org/scip/anydb/rest"
"github.com/spf13/cobra"
)
func Export(conf *cfg.Config) *cobra.Command {
@@ -57,6 +58,7 @@ func Export(conf *cfg.Config) *cobra.Command {
}
cmd.PersistentFlags().StringVarP(&attr.File, "output-file", "o", "", "filename or - for STDIN")
if err := cmd.MarkPersistentFlagRequired("output-file"); err != nil {
panic(err)
}
@@ -86,12 +88,14 @@ func Import(conf *cfg.Config) *cobra.Command {
}
fmt.Print(out)
return nil
},
}
cmd.PersistentFlags().StringVarP(&attr.File, "import-file", "i", "", "filename or - for STDIN")
cmd.PersistentFlags().StringArrayVarP(&attr.Tags, "tags", "t", nil, "tags, multiple allowed")
if err := cmd.MarkPersistentFlagRequired("import-file"); err != nil {
panic(err)
}
@@ -124,7 +128,6 @@ func Man(conf *cfg.Config) *cobra.Command {
man.Stderr = os.Stderr
err := man.Run()
if err != nil {
return fmt.Errorf("failed to execute 'less': %w", err)
}
@@ -205,19 +208,20 @@ func Edit(conf *cfg.Config) *cobra.Command {
return err
}
if len(entry.Value) == 0 && entry.Binary {
if len(entry.GetValue()) == 0 && entry.GetBinary() {
return errors.New("key contains binary uneditable content")
}
// decrypt if needed
if entry.Encrypted {
if entry.GetEncrypted() {
pass, err := getPassword()
if err != nil {
return err
}
password = pass
clear, err := app.Decrypt(pass, []byte(entry.Value))
clear, err := app.Decrypt(pass, []byte(entry.GetValue()))
if err != nil {
return err
}
@@ -232,7 +236,7 @@ func Edit(conf *cfg.Config) *cobra.Command {
// save file to a temp file, call the editor with it, read
// it back in and compare the content with the original
// one
newcontent, err := editContent(editor, string(entry.Value))
newcontent, err := editContent(editor, entry.GetValue())
if err != nil {
return err
}
@@ -328,7 +332,7 @@ func editContent(editor string, content string) (string, error) {
newcontentstr := string(newcontent)
if content == newcontentstr {
return "", fmt.Errorf("content not modified, aborting")
return "", errors.New("content not modified, aborting")
}
return newcontentstr, nil