github.com/vmware/govmomi@v0.37.2/govc/usage.sh (about)

     1  #!/bin/bash -e
     2  
     3  for var in $(env | grep GOVC_) ; do
     4    eval "unset ${var/=*}"
     5  done
     6  
     7  common_opts=$(cat <<EOF
     8    -h                        Show this message
     9    -cert=                    Certificate [GOVC_CERTIFICATE]
    10    -debug=false              Store debug logs [GOVC_DEBUG]
    11    -trace=false              Write SOAP/REST traffic to stderr
    12    -verbose=false            Write request/response data to stderr
    13    -dump=false               Enable output dump
    14    -json=false               Enable JSON output
    15    -xml=false                Enable XML output
    16    -k=false                  Skip verification of server certificate [GOVC_INSECURE]
    17    -key=                     Private key [GOVC_PRIVATE_KEY]
    18    -persist-session=true     Persist session to disk [GOVC_PERSIST_SESSION]
    19    -tls-ca-certs=            TLS CA certificates file [GOVC_TLS_CA_CERTS]
    20    -tls-known-hosts=         TLS known hosts file [GOVC_TLS_KNOWN_HOSTS]
    21    -u=                       ESX or vCenter URL [GOVC_URL]
    22    -vim-namespace=urn:vim25  Vim namespace [GOVC_VIM_NAMESPACE]
    23    -vim-version=6.0          Vim version [GOVC_VIM_VERSION]
    24    -dc=                      Datacenter [GOVC_DATACENTER]
    25    -host.dns=                Find host by FQDN
    26    -host.ip=                 Find host by IP address
    27    -host.ipath=              Find host by inventory path
    28    -host.uuid=               Find host by UUID
    29    -vm.dns=                  Find VM by FQDN
    30    -vm.ip=                   Find VM by IP address
    31    -vm.ipath=                Find VM by inventory path
    32    -vm.path=                 Find VM by path to .vmx file
    33    -vm.uuid=                 Find VM by UUID
    34  EOF
    35  )
    36  
    37  cat <<'EOF'
    38  # govc usage
    39  
    40  This document is generated from `govc -h` and `govc $cmd -h` commands.
    41  
    42  The following common options are filtered out in this document,
    43  but appear via `govc $cmd -h`:
    44  
    45  ```
    46  EOF
    47  
    48  printf "%s\n\`\`\`\n\n" "${common_opts}"
    49  
    50  cmds=($(govc -h | sed '1,/^Available commands:$/d'))
    51  
    52  opts=($(cut -s -d= -f1 <<<"$common_opts" | xargs -n1))
    53  filter=$(printf "|%s=" "${opts[@]}")
    54  
    55  printf "<details><summary>Contents</summary>\n\n"
    56  for cmd in "${cmds[@]}" ; do
    57      printf " - [%s](#%s)\n" "$cmd" "${cmd//./}"
    58  done
    59  printf "\n</details>\n\n"
    60  
    61  for cmd in "${cmds[@]}" ; do
    62      printf "## %s\n\n" "$cmd"
    63      printf "\`\`\`\n"
    64      govc "$cmd" -h | grep -E -v -- "${filter:1}"
    65      printf "\`\`\`\n\n"
    66  done