fix
- check CHANGELOG.md ver 0.2.1-alpha
This commit is contained in:
1 parent
a8f164c241
commit
9434b02422
8 files changed
+59
-7
No files matched your search
@@ -2,6 +2,14 @@
|
||||
|
||||
## [Latest]
|
||||
|
||||
## [0.2.1-alpha]- 2026-8-14
|
||||
|
||||
### Fixed
|
||||
- Prevented creating spells with reserved names
|
||||
- Improved error messages
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.2.0-alpha] - 2026-08-08
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# spellbook 0.1.0-alpha
|
||||
# spellbook 0.2.1-alpha
|
||||
|
||||
`spellbook` is a lightweight CLI command manager written in Go. It allows you to save complex shell commands as parameterized templates ("spells") and execute them instantly with custom arguments.
|
||||
|
||||
@@ -106,4 +106,5 @@ spellbook my-spell target=127.0.0.1
|
||||
---
|
||||
|
||||
## Upcoming Features
|
||||
- Search to navigate your spell book
|
||||
- Search to navigate your spell book
|
||||
- Export/import spellbooks
|
||||
+3
-1
@@ -43,5 +43,7 @@ func main() {
|
||||
|
||||
c := cli.NewCLI(app)
|
||||
|
||||
handleErr(c.Run(ctx))
|
||||
if err := c.Run(ctx); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
errors2 "github.com/abelith/spellbook/internal/errors"
|
||||
"github.com/abelith/spellbook/internal/models"
|
||||
"github.com/google/shlex"
|
||||
"os/exec"
|
||||
@@ -40,7 +41,7 @@ func (sc *SpellCaster) Cast(ctx context.Context, cast models.SpellCast) (models.
|
||||
res.Err = err
|
||||
return res, nil
|
||||
}
|
||||
return res, fmt.Errorf("failed to cast spell: %w", err)
|
||||
return res, fmt.Errorf("%w: %w", errors2.ErrFailedToCast, err)
|
||||
}
|
||||
|
||||
res.ExitCode = 0
|
||||
|
||||
@@ -3,7 +3,7 @@ package sqlite
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/abelith/spellbook/internal/errors"
|
||||
"github.com/abelith/spellbook/internal/models"
|
||||
"strings"
|
||||
)
|
||||
@@ -33,7 +33,7 @@ func NewRepo(db *sql.DB) *Repo {
|
||||
|
||||
func (r *Repo) Init(ctx context.Context) error {
|
||||
if r.db == nil {
|
||||
return fmt.Errorf("no db provided")
|
||||
return errors.ErrNoDBProvided
|
||||
}
|
||||
|
||||
if _, err := r.db.ExecContext(ctx, schema); err != nil {
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/abelith/spellbook/internal/errors"
|
||||
"github.com/abelith/spellbook/internal/models"
|
||||
"github.com/spf13/cobra"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var reservedCommands = map[string]struct{}{
|
||||
"add": {},
|
||||
"rm": {},
|
||||
"help": {},
|
||||
"completion": {},
|
||||
}
|
||||
|
||||
func NewAddCommand(app Application) *cobra.Command {
|
||||
spell := models.Spell{}
|
||||
|
||||
@@ -16,6 +25,14 @@ func NewAddCommand(app Application) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
ctx := cmd.Context()
|
||||
|
||||
if len(args) < 1 {
|
||||
return errors.ErrInsufficientArgs
|
||||
}
|
||||
|
||||
if isReservedCommand(args[0]) {
|
||||
return fmt.Errorf("%w: %s", errors.ErrReservedCmd, args[0])
|
||||
}
|
||||
|
||||
spell.Spell = strings.Join(args, " ")
|
||||
return app.AddSpell(ctx, spell)
|
||||
},
|
||||
@@ -27,3 +44,8 @@ func NewAddCommand(app Application) *cobra.Command {
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func isReservedCommand(cmd string) bool {
|
||||
_, reserved := reservedCommands[strings.ToLower(cmd)]
|
||||
return reserved
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package cli
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/abelith/spellbook/internal/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewRmCommand(app Application) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
@@ -10,6 +14,10 @@ func NewRmCommand(app Application) *cobra.Command {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
ctx := cmd.Context()
|
||||
|
||||
if len(args) < 1 {
|
||||
return fmt.Errorf("%w: %s", errors.ErrInsufficientArgs, "spell_name")
|
||||
}
|
||||
|
||||
return app.DeleteSpell(ctx, args[0])
|
||||
},
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package errors
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
ErrReservedCmd = fmt.Errorf("command name is reserved")
|
||||
ErrInsufficientArgs = fmt.Errorf("mandatory args are missing")
|
||||
ErrFailedToCast = fmt.Errorf("failed to cast spell")
|
||||
ErrNoDBProvided = fmt.Errorf("no db provided")
|
||||
)
|
||||
Reference in new issue
Block a user