Skip to content

Commit

Permalink
optimize: add flag use comment
Browse files Browse the repository at this point in the history
  • Loading branch information
chaunsin committed Aug 31, 2023
1 parent c988475 commit d9dd2ce
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 39 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Qodana](https://github.com/chaunsin/fgc/actions/workflows/qodana_code_quality.yml/badge.svg?branch=master)](https://github.com/chaunsin/fgc/actions/workflows/qodana_code_quality.yml)

由于fabric证书配置复杂编写配置容易搞错,本人想着便捷于是诞生了此工具,生成sdk链接配置文件.
由于fabric证书配置复杂编写配置容易搞错,本人想着便捷于是诞生了此工具,用于生成sdk链接配置文件.

# 注意!!!

Expand All @@ -26,14 +26,21 @@ cd fgc
make install
```

执行完之后会在fgc目录下生成`fgc`可执行程序,如果有必要我们可以把fgc拷贝到自定一位置比如 /bin 目录下
执行之后会在fgc目录下生成`fgc`可执行文件,如果有必要我们可以把可执行文件拷贝到自定义位置比如`/bin`目录下

# 使用

生成golang配置证书
生成fabric-sdk-go sdk链接配置证书

```shell
fgc go
# tips: crypto-config为fabric证书目录
fgc go -i ./crypto-config
```

帮助

```shell
fgc -h
```

# 功能
Expand All @@ -43,8 +50,8 @@ fgc go
- [ ] 支持java普通配置文件生成
- [ ] 支持nodejs普通配置文件生成
- [ ] 配置文件格式
- [x] 支持生成yaml配置文件
- [ ] 支持生成json配置文件(目前能生成但是配置文件未必能使用)
- [x] 支持生成yaml配置文件
- [ ] 支持生成json配置文件(目前能生成但是配置文件未必能使用)
- [ ] 支持生成gateway链接配置文件
- [ ] golang网关钱包配置生成
- [ ] java网关钱包配置生成
Expand Down
18 changes: 9 additions & 9 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func New() *Cmd {
c := &Cmd{
root: &cobra.Command{
Use: "fgc",
Example: "fgc golang",
Example: "fgc golang -i ./crypto-config",
},
}
c.addFlags()
Expand All @@ -41,21 +41,21 @@ func New() *Cmd {
func (c *Cmd) addFlags() {
c.root.PersistentFlags().BoolVar(&c.RootOpts.Debug, "debug", false, "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.Input, "input", "i", defaultString("FABRIC_CFG_PATH", "./crypto-config"), "gen [command] -i ./crypto-config")
c.root.PersistentFlags().StringVarP(&c.RootOpts.Output, "output", "p", "./", "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.Output, "output", "p", "./", "Generate file directory location")
c.root.PersistentFlags().BoolVar(&c.RootOpts.Stdout, "stdout", false, "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.FileType, "type", "t", "yaml", "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.FileType, "type", "t", "yaml", "Generated file type")
c.root.PersistentFlags().StringVarP(&c.RootOpts.Service, "service", "s", "normal", "")
c.root.PersistentFlags().BoolVar(&c.RootOpts.Pem, "pem", false, "")
c.root.PersistentFlags().BoolVar(&c.RootOpts.DoubleTls, "tls", false, "")
c.root.PersistentFlags().BoolVar(&c.RootOpts.DoubleTls, "tls", false, "Whether to enable bidirectional TLS authentication. The default value is unidirectional")
c.root.PersistentFlags().BoolVar(&c.RootOpts.CA, "ca", false, "")
c.root.PersistentFlags().BoolVar(&c.RootOpts.Metrics, "metrics", false, "")
c.root.PersistentFlags().BoolVar(&c.RootOpts.Operations, "operations", false, "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.OrgName, "org", "o", "org1", "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.OrderName, "order", "O", "order", "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.ChannelName, "channel", "c", "mychannel", "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.User, "user", "u", "Admin", "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.OrgName, "org", "o", "org1", "Organization name")
c.root.PersistentFlags().StringVarP(&c.RootOpts.OrderName, "order", "O", "order", "Orderer name")
c.root.PersistentFlags().StringVarP(&c.RootOpts.ChannelName, "channel", "c", "mychannel", "The name of the channel used")
c.root.PersistentFlags().StringVarP(&c.RootOpts.User, "user", "u", "Admin", "The user name used")
c.root.PersistentFlags().StringVarP(&c.RootOpts.Mode, "mode", "m", "local", "local,sftp,ftp")
c.root.PersistentFlags().StringVarP(&c.RootOpts.Addr, "host", "H", "", "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.Addr, "host", "H", "", "Service ip address or domain name")
c.root.PersistentFlags().StringVarP(&c.RootOpts.Username, "username", "U", "root", "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.Password, "password", "P", "", "")
c.root.PersistentFlags().StringVarP(&c.RootOpts.PrivateKey, "key", "k", ".ssh/key.pem", "")
Expand Down
2 changes: 1 addition & 1 deletion cmd/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func newGolangCmd(c *Cmd) *cobra.Command {
}
s.cmd = &cobra.Command{
Use: "go",
Short: "golang",
Short: "Generate fabric-sdk-go config file",
RunE: func(cmd *cobra.Command, args []string) error {
return s.generate()
},
Expand Down
20 changes: 9 additions & 11 deletions cmd/java.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package cmd

import "github.com/spf13/cobra"
import (
"errors"

"github.com/spf13/cobra"
)

type javaCmd struct {
cli *Cmd
cmd *cobra.Command
cli *Cmd
cmd *cobra.Command

root string
contractAccount string
Expand All @@ -19,7 +23,7 @@ func newJavaCmd(c *Cmd) *cobra.Command {
}
s.cmd = &cobra.Command{
Use: "java",
Short: "java",
Short: "Generate fabric-sdk-java config file",
RunE: func(cmd *cobra.Command, args []string) error {
return s.handler()
},
Expand All @@ -31,14 +35,8 @@ func newJavaCmd(c *Cmd) *cobra.Command {
}

func (s *javaCmd) addFlags() {
s.cmd.Flags().StringVarP(&s.root, "root", "r", "./keys", "root账户配置文件位置")
s.cmd.Flags().StringVarP(&s.mnemonic, "mnemonic", "m", "", "中文助记词,如果设置则使用当前设置的账号来创建合约账户")
s.cmd.Flags().StringVarP(&s.contractAccount, "contractAccount", "c", "XC2222222222222222@xuper", "合约账号")
s.cmd.Flags().StringVarP(&s.fee, "fee", "f", "999999999", "转账金额")
s.cmd.Flags().StringVarP(&s.password, "password", "P", "123456", "公私钥文件密码")
}

func (s *javaCmd) handler() error {

return nil
return errors.New("该命令暂不支持")
}
22 changes: 10 additions & 12 deletions cmd/nodejs.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package cmd

import "github.com/spf13/cobra"
import (
"errors"

"github.com/spf13/cobra"
)

type nodejsCmd struct {
cli *Cmd
cmd *cobra.Command
cli *Cmd
cmd *cobra.Command

root string
contractAccount string
fee string
password string
mnemonic string
mnemonic string
}

func newNodeJSCmd(c *Cmd) *cobra.Command {
Expand All @@ -19,7 +23,7 @@ func newNodeJSCmd(c *Cmd) *cobra.Command {
}
s.cmd = &cobra.Command{
Use: "nodejs",
Short: "nodejs",
Short: "Generate fabric-sdk-node config file",
RunE: func(cmd *cobra.Command, args []string) error {
return s.handler()
},
Expand All @@ -31,14 +35,8 @@ func newNodeJSCmd(c *Cmd) *cobra.Command {
}

func (s *nodejsCmd) addFlags() {
s.cmd.Flags().StringVarP(&s.root, "root", "r", "./keys", "root账户配置文件位置")
s.cmd.Flags().StringVarP(&s.mnemonic, "mnemonic", "m", "", "中文助记词,如果设置则使用当前设置的账号来创建合约账户")
s.cmd.Flags().StringVarP(&s.contractAccount, "contractAccount", "c", "XC2222222222222222@xuper", "合约账号")
s.cmd.Flags().StringVarP(&s.fee, "fee", "f", "999999999", "转账金额")
s.cmd.Flags().StringVarP(&s.password, "password", "P", "123456", "公私钥文件密码")
}

func (s *nodejsCmd) handler() error {

return nil
return errors.New("该命令暂不支持")
}

0 comments on commit d9dd2ce

Please sign in to comment.