@@ -4,32 +4,9 @@ import (
44 "errors"
55 "fmt"
66 "os"
7- "strconv"
87 "strings"
98)
109
11- var (
12- Int = NewTransfer ("int" , func (s string ) (any , error ) {
13- if i , err := strconv .ParseInt (s , 10 , 0 ); err != nil {
14- return 0 , err
15- } else {
16- return int (i ), nil
17- }
18- })
19-
20- String = NewTransfer ("string" , func (s string ) (any , error ) {
21- return s , nil
22- })
23-
24- Bool = NewTransfer ("int" , func (s string ) (any , error ) {
25- if len (s ) == 0 {
26- return true , nil
27- } else {
28- return false , errors .New ("boolean requires no value" )
29- }
30- })
31- )
32-
3310type DefaultValue struct {
3411 name string
3512 value any
@@ -119,7 +96,7 @@ func (t *Tabby) Run(rawArgs []string) (*TabbyContainer, error) {
11996 subApp , ok = app .SubApplication (appName )
12097 if ! ok {
12198 if t .unknownApp == nil {
122- return nil , fmt .Errorf ("App '%s' not exists" , strings .Join (appPath , "/" ))
99+ return nil , fmt .Errorf ("application '%s' not exists" , strings .Join (appPath , "/" ))
123100 } else {
124101 app = t .unknownApp
125102 if err := app .Init (t .mainApp ); err != nil {
@@ -151,7 +128,7 @@ func (t *Tabby) Run(rawArgs []string) (*TabbyContainer, error) {
151128 for _ , alia := range param .alias {
152129 if v , ok := strArgs [alia ]; ok {
153130 if value , err1 := param .defaultValue .transfer (v ); err1 != nil {
154- return nil , fmt .Errorf ("App '%s': argument '%s(%s)' :error: %s" , finalAppPath , param .identify , param .defaultValue .name , err1 .Error ())
131+ return nil , fmt .Errorf ("application '%s': argument '%s(%s)' :error: %s" , finalAppPath , param .identify , param .defaultValue .name , err1 .Error ())
155132 } else {
156133 args [param .identify ] = value
157134 empty = false
@@ -161,11 +138,19 @@ func (t *Tabby) Run(rawArgs []string) (*TabbyContainer, error) {
161138 }
162139 }
163140
141+ if empty {
142+ tc , err := app .EmptyMain ()
143+ if err != nil {
144+ return nil , errors .New ("App '" + finalAppPath + "' error:" + err .Error ())
145+ }
146+ return tc , nil
147+ }
148+
164149 if len (strArgs ) > 0 && ! app .IgnoreUnsupportedArgs () {
165150 return nil , fmt .Errorf (
166- "App '%s': unsupported parameters '%s'" ,
151+ "application '%s': unsupported parameters '%s'" ,
167152 finalAppPath ,
168- strings .Join (AddPrefix (MapKeys [ string , string ] (strArgs ), "-" ), "," ))
153+ strings .Join (AddPrefix (MapKeys (strArgs ), "-" ), "," ))
169154 }
170155
171156 //DefaultArgs
@@ -175,7 +160,7 @@ func (t *Tabby) Run(rawArgs []string) (*TabbyContainer, error) {
175160 args [param .identify ] = param .defaultValue .value
176161 } else if ! empty {
177162 return nil , fmt .Errorf (
178- "App '%s': required parameter '%s' not provided(%s)" ,
163+ "application '%s': required parameter '%s' not provided(%s)" ,
179164 finalAppPath , param .identify ,
180165 strings .Join (AddPrefix (param .alias , "-" ), "," ))
181166 }
0 commit comments