Skip to content

Commit

Permalink
improved tiny app codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hedzr committed Oct 21, 2024
1 parent cefb7ab commit 2d34741
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func prepareApp(opts ...cli.Opt) (app cli.App) {
Description("a wrong command to return error for testing").
// cmdline `FORCE_RUN=1 go run ./tiny wrong -d 8s` to verify this command to see the returned application error.
OnAction(func(ctx context.Context, cmd cli.Cmd, args []string) (err error) {
dur := cmdr.CmdStore().MustDuration("wrong.duration")
dur := cmd.Store().MustDuration("wrong.duration")
println("the duration is:", dur.String())

ec := errors.New()
Expand Down
5 changes: 3 additions & 2 deletions tiny/litecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ func (s *liteCmdS) GetTitleName() string { return s.name() }
func (s *liteCmdS) GetTitleNamesArray() []string { return []string{s.name()} }
func (s *liteCmdS) GetTitleNames() string { return s.name() }

func (s *liteCmdS) App() cli.App { return nil }
func (s *liteCmdS) Set() store.Store { return s.Root().App().Store() }
func (s *liteCmdS) App() cli.App { return nil }
func (s *liteCmdS) Set() store.Store { return s.Root().App().Store() }
func (s *liteCmdS) Store() store.Store { return cmdr.CmdStore() }

func (s *liteCmdS) OwnerIsValid() bool {
if s.OwnerIsNotNil() {
Expand Down
2 changes: 1 addition & 1 deletion tiny/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func prepareApp(opts ...cli.Opt) (app cli.App) {
Description("a wrong command to return error for testing").
// cmdline `FORCE_RUN=1 go run ./tiny wrong -d 8s` to verify this command to see the returned application error.
OnAction(func(ctx context.Context, cmd cli.Cmd, args []string) (err error) {
dur := cmdr.CmdStore().MustDuration("wrong.duration")
dur := cmd.Store().MustDuration("wrong.duration")
println("the duration is:", dur.String())

ec := errors.New()
Expand Down
2 changes: 1 addition & 1 deletion tiny/tiny/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func prepareApp(opts ...cli.Opt) (app cli.App) {
Description("a wrong command to return error for testing").
// cmdline `FORCE_RUN=1 go run ./tiny wrong -d 8s` to verify this command to see the returned application error.
OnAction(func(ctx context.Context, cmd cli.Cmd, args []string) (err error) {
dur := cmdr.CmdStore().MustDuration("wrong.duration")
dur := cmd.Store().MustDuration("wrong.duration")
println("the duration is:", dur.String())

ec := errors.New()
Expand Down

0 comments on commit 2d34741

Please sign in to comment.