cobraLab

command module
v0.0.0-...-9bc398e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

README

CobraLab

A place to experiment with Cobra and Viper

Why?

Cobra and Viper are powerful tools, with minimal documentation, as the primary author is crazy busy being a Golang core contributor. Cobra's docs lag behind the code, for example, when I created this, the examples on Cobra's generator page did not work as given (you have to run go mod init [module] where [module] is the same as what you gave as --pkg-name in cobra init).

I wanted a minimal environment in which I could explore what was actually happening under the hood with Cobra, Viper, PFlag, Mapstructure, etc. A way to test hypotheses I would make about behavior based on reading the code.

Examples

  1. Multilevel modern

    Multilevel commands, but uses the community pattern for CLIs, with cmd/cobraLab/main.go.

  2. Multilevel command

    Has multilevel commands:

cobraLab k8s cluster
cobraLab k8s options

where cobraLab k8s is not Runnable. Cobra shows help in all the various ways (--help, help k8s, and cobraLab k8s) despite the open issue to the contrary.

  1. Generator page

    generator_page_example has the example from the README for Cobra's generator. Works fine once you run go mod init [module] as discussed above.

Documentation

Overview

Copyright © 2019 Hilary J Holz <holz.hilary@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL