gcli icon indicating copy to clipboard operation
gcli copied to clipboard

关于交互式建议

Open hb0730 opened this issue 2 years ago • 5 comments

  1. interact.ReadLine 是否新增必填选项

  2. interact.SelectOne

     SelectOne(title string, options interface{}, defOpt string, allowQuit ...bool)
    

    既然默认值已经是string,那optionsinterface是否能够确认类型, 好像defOpt只能是字符串下标

    image 这种可能想要的只是bool

参考 promptui

hb0730 avatar Jul 26 '22 07:07 hb0730

原来实现的比较简单。一直也没时间进一步优化改进 :)

有兴趣可以参与改进下

inhere avatar Jul 26 '22 08:07 inhere

@inhere Command Cli时好像无法正确解析bool类型

1658899319246

image

image

hb0730 avatar Jul 27 '22 05:07 hb0730

这是参照 go flag 的逻辑处理的。 bool 值一般不会主动通过输入设置false,因为默认就是false。 要设置只能 -f=false。 go flag 底层没改的话应该也是这样的

inhere avatar Jul 27 '22 06:07 inhere

@inhere 也试过 go flag方式init -f=false vue-test

会提示错误

ERROR: option error - bad flag syntax: -=

image

hb0730 avatar Jul 27 '22 09:07 hb0730

👍 哦 看到调试信息,好像知道哪里错误了

inhere avatar Jul 27 '22 11:07 inhere