zoukankan      html  css  js  c++  java
  • go cobra

    https://github.com/spf13/cobra

    https://github.com/spf13/cobra/blob/master/bash_completions.md

    go get github.com/spf13/cobra/cobra

    cobra init cobratest

    main.go 目录下

    cobra add serve
    cobra add config
    cobra add create -p 'configCmd'

    Persistent Flags

    一个标志可以是“持久的”,这意味着这个标志将被分配的命令以及该命令下的每个命令都可用。 对于全局标志,在根上分配一个标志作为持久标志。

    Local Flags

    一个标志也可以在本地分配,只适用于该特定的命令。

    Local Flag on Parent Commands

    默认情况下,Cobra只解析目标命令的本地标志,父命令的任何本地标志都被忽略。 通过启用Command.TraverseChildren Cobra将在执行目标命令之前分析每个命令上的本地标志。

    command := cobra.Command{
      Use: "print [OPTIONS] [COMMANDS]",
      TraverseChildren: true,
    }

    https://github.com/spf13/viper#working-with-flags

  • 相关阅读:
    2017ICPC南宁补题
    H. The Game of Life
    I
    Twice Equation
    (贪心+队列)String
    Marcin and Training Camp
    莫比乌斯函数模版
    HDU-1695 莫比乌斯反演
    Steps to One DP+莫比乌斯反演
    Educational Codeforces Round 62 (Rated for Div. 2)
  • 原文地址:https://www.cnblogs.com/mhc-fly/p/7800552.html
Copyright © 2011-2022 走看看