yunion.io/x/cloudmux@v0.3.10-0-alpha.1/cmd/cmx/shell/options.go (about)

     1  // Copyright 2019 Yunion
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package shell
    16  
    17  type GlobalOptions struct {
    18  	Debug      bool   `help:"Debug mode"`
    19  	SUBCOMMAND string `help:"Cloudmux client subcommand" subcommand:"true"`
    20  
    21  	Provider string `help:"Cloud provider" required:"true" choices:"Aliyun|Aws|Azure|Qcloud"`
    22  
    23  	CloudEnv  string `help:"Cloud environment" default:"$CLOUDMUX_CLOUD_ENV" choices:"InternationalCloud|FinanceCloud|ChinaCloud|AzureGermanCloud|AzureChinaCloud|AzureUSGovernmentCloud|AzurePublicCloud" metavar:"CLOUDMUX_CLOUD_ENV"`
    24  	AccessKey string `help:"Access key" default:"$CLOUDMUX_ACCESS_KEY" metavar:"CLOUDMUX_ACCESS_KEY"`
    25  	Secret    string `help:"Secret" default:"$CLOUDMUX_SECRET" metavar:"CLOUDMUX_SECRET"`
    26  	Region    string `help:"Default region" default:"$CLOUDMUX_REGION" metavar:"CLOUDMUX_REGION" short-token:"r"`
    27  }
    28  
    29  type EmptyOption struct{}
    30  
    31  type IListOption interface {
    32  	GetLimit() int
    33  	GetOffset() int
    34  	IsDetails() bool
    35  	GetColumns() []string
    36  }
    37  
    38  type ListBaseOptions struct {
    39  	Limit   int  `help:"Page size"`
    40  	Offset  int  `help:"Page offset"`
    41  	Details bool `help:"Show Details"`
    42  }
    43  
    44  func (o ListBaseOptions) GetLimit() int {
    45  	return o.Limit
    46  }
    47  
    48  func (o ListBaseOptions) GetOffset() int {
    49  	return o.Offset
    50  }
    51  
    52  func (o ListBaseOptions) IsDetails() bool {
    53  	return o.Details
    54  }
    55  
    56  func (o ListBaseOptions) GetColumns() []string {
    57  	return nil
    58  }
    59  
    60  type IZoneBaseOptions interface {
    61  	GetZoneId() string
    62  }
    63  
    64  type ZoneBaseOptions struct {
    65  	Zone string `help:"Zone ID"`
    66  }
    67  
    68  func (o ZoneBaseOptions) GetZoneId() string {
    69  	return o.Zone
    70  }
    71  
    72  type IHostBaseOptions interface {
    73  	IZoneBaseOptions
    74  	GetHostId() string
    75  }
    76  
    77  type HostBaseOptions struct {
    78  	ZoneBaseOptions
    79  	Host string `help:"Host ID"`
    80  }
    81  
    82  func (o HostBaseOptions) GetHostId() string {
    83  	return o.Host
    84  }