Documentation
¶
Overview ¶
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CreateCmd = &cobra.Command{ Use: "create [flags]", Aliases: []string{"crt", "c"}, Short: "Create Exchange rate", RunE: func(cmd *cobra.Command, args []string) error { var ( from int to int rate float64 ) from, err := cmd.Flags().GetInt("from") if err != nil || from == -1 { return errors.New("empty from") } to, err = cmd.Flags().GetInt("to") if err != nil || to == -1 { return errors.New("empty to") } rate, err = cmd.Flags().GetFloat64("rate") if err != nil { return errors.New("empty rate") } ctx, client := MakeCurrencyServiceClientOrFail() res, err := client.CreateExchangeRate(ctx, &proto.CreateExchangeRateRequest{ From: proto.Currency(from), To: proto.Currency(to), Rate: rate, }) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Println("Successfully created ", res) } return nil }, }
var DeleteCmd = &cobra.Command{ Use: "delete [flags]", Aliases: []string{"del", "rm", "r"}, Short: "Delete exchange rate", Args: cobra.MinimumNArgs(0), RunE: func(cmd *cobra.Command, args []string) error { var ( from int to int ) from, err := cmd.Flags().GetInt("from") if err != nil || from == -1 { return errors.New("empty from") } to, err = cmd.Flags().GetInt("to") if err != nil || to == -1 { return errors.New("empty to") } ctx, client := MakeCurrencyServiceClientOrFail() res, err := client.DeleteExchangeRate(ctx, &proto.DeleteExchangeRateRequest{ From: proto.Currency(from), To: proto.Currency(to), }) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Println("Success deleted ", res) } return nil }, }
DeleteCmd represents the delete command
var GetCmd = &cobra.Command{ Use: "get [flags]", Short: "Get exchange rate", Args: cobra.MinimumNArgs(0), RunE: func(cmd *cobra.Command, args []string) error { var ( from int to int ) from, err := cmd.Flags().GetInt("from") if err != nil || from == -1 { return errors.New("empty from") } to, err = cmd.Flags().GetInt("to") if err != nil || to == -1 { return errors.New("empty to") } ctx, client := MakeCurrencyServiceClientOrFail() res, err := client.GetExchangeRate(ctx, &proto.GetExchangeRateRequest{ From: proto.Currency(from), To: proto.Currency(to), }) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Println("Successfully fetched ", res) } return nil }, }
GetCmd represents the get command
var ListCurrenciesCmd = &cobra.Command{ Use: "currencies", Aliases: []string{"curs"}, Short: "List currencies", Args: cobra.MinimumNArgs(0), RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakeCurrencyServiceClientOrFail() curs, err := client.GetCurrencies(ctx, &proto.GetCurrenciesRequest{}) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, curs) if err != nil { return err } if !ok { fmt.Println("Successfully fetched ", curs) } return nil }, }
ListCurrenciesCmd represents the list currencies command
var ListRatesCmd = &cobra.Command{ Use: "rates", Aliases: []string{"exchangerates"}, Short: "List exchange rates", Args: cobra.MinimumNArgs(0), RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakeCurrencyServiceClientOrFail() rates, err := client.GetExchangeRates(ctx, &proto.GetExchangeRatesRequest{}) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, rates) if err != nil { return err } if !ok { fmt.Println("Successfully fetched ", rates) } return nil }, }
ListRatesCmd represents the list rates command
var UpdateCmd = &cobra.Command{ Use: "update [flags]", Aliases: []string{"upd", "u"}, Short: "Update Exchange rate", RunE: func(cmd *cobra.Command, args []string) error { var ( from int to int rate float64 ) from, err := cmd.Flags().GetInt("from") if err != nil || from == -1 { return errors.New("empty from") } to, err = cmd.Flags().GetInt("to") if err != nil || to == -1 { return errors.New("empty to") } rate, err = cmd.Flags().GetFloat64("rate") if err != nil { return errors.New("empty rate") } ctx, client := MakeCurrencyServiceClientOrFail() res, err := client.UpdateExchangeRate(ctx, &proto.UpdateExchangeRateRequest{ From: proto.Currency(from), To: proto.Currency(to), Rate: rate, }) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Println("Successfully updated ", res) } return nil }, }
Functions ¶
func MakeCurrencyServiceClientOrFail ¶
func MakeCurrencyServiceClientOrFail() (context.Context, pb.CurrencyServiceClient)
Types ¶
This section is empty.