diff options
author | asmyasnikov <asmyasnikov@ydb.tech> | 2022-10-27 15:48:56 +0300 |
---|---|---|
committer | asmyasnikov <asmyasnikov@ydb.tech> | 2022-10-27 15:48:56 +0300 |
commit | e73f8297c5d736639dd17d7a538a15d02e5dc655 (patch) | |
tree | d00d48bd0a3916db51315c1530b84f073faac4ad | |
parent | 347c17bf6e17b81510b629e27897640b08bc8c4b (diff) | |
download | ydb-e73f8297c5d736639dd17d7a538a15d02e5dc655.tar.gz |
add application name as required parameter into root command
add application name as required parameter
-rw-r--r-- | ydb/apps/ydb/commands/ydb_cloud_root.cpp | 12 | ||||
-rw-r--r-- | ydb/apps/ydb/commands/ydb_cloud_root.h | 4 | ||||
-rw-r--r-- | ydb/core/driver_lib/cli_utils/cli.h | 2 | ||||
-rw-r--r-- | ydb/core/driver_lib/cli_utils/cli_cmds_root.cpp | 12 | ||||
-rw-r--r-- | ydb/core/driver_lib/run/main.cpp | 4 | ||||
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp | 4 | ||||
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_root_common.h | 2 |
7 files changed, 23 insertions, 17 deletions
diff --git a/ydb/apps/ydb/commands/ydb_cloud_root.cpp b/ydb/apps/ydb/commands/ydb_cloud_root.cpp index 0a836f801cb..0d1cb952510 100644 --- a/ydb/apps/ydb/commands/ydb_cloud_root.cpp +++ b/ydb/apps/ydb/commands/ydb_cloud_root.cpp @@ -5,11 +5,13 @@ #include <ydb/public/sdk/cpp/client/iam/iam.h> #include <ydb/public/lib/ydb_cli/common/ydb_updater.h> +#include <filesystem> + namespace NYdb { namespace NConsoleClient { -TClientCommandRoot::TClientCommandRoot(const TClientSettings& settings) - : TClientCommandRootCommon(settings) +TClientCommandRoot::TClientCommandRoot(const TString& name, const TClientSettings& settings) + : TClientCommandRootCommon(name, settings) { } @@ -45,8 +47,8 @@ void TClientCommandRoot::SetCredentialsGetter(TConfig& config) { }; } -TYCloudClientCommandRoot::TYCloudClientCommandRoot(const TClientSettings& settings) - : TClientCommandRoot(settings) +TYCloudClientCommandRoot::TYCloudClientCommandRoot(const TString& name, const TClientSettings& settings) + : TClientCommandRoot(name, settings) { AddCommand(std::make_unique<TCommandUpdate>()); AddCommand(std::make_unique<TCommandVersion>()); @@ -101,7 +103,7 @@ int NewYCloudClient(int argc, char** argv) { settings.MentionUserAccount = false; settings.YdbDir = "ydb"; - THolder<TYCloudClientCommandRoot> commandsRoot = MakeHolder<TYCloudClientCommandRoot>(settings); + auto commandsRoot = MakeHolder<TYCloudClientCommandRoot>(std::filesystem::path(argv[0]).stem().string(), settings); commandsRoot->Opts.SetTitle("YDB client for Yandex.Cloud"); TClientCommand::TConfig config(argc, argv); return commandsRoot->Process(config); diff --git a/ydb/apps/ydb/commands/ydb_cloud_root.h b/ydb/apps/ydb/commands/ydb_cloud_root.h index 982f9d6b87a..c184eec7c56 100644 --- a/ydb/apps/ydb/commands/ydb_cloud_root.h +++ b/ydb/apps/ydb/commands/ydb_cloud_root.h @@ -7,7 +7,7 @@ namespace NConsoleClient { class TClientCommandRoot : public TClientCommandRootCommon { public: - TClientCommandRoot(const TClientSettings& settings); + TClientCommandRoot(const TString& name, const TClientSettings& settings); private: void FillConfig(TConfig& config) override; @@ -16,7 +16,7 @@ private: class TYCloudClientCommandRoot : public TClientCommandRoot { public: - TYCloudClientCommandRoot(const TClientSettings& settings); + TYCloudClientCommandRoot(const TString& name, const TClientSettings& settings); void Config(TConfig& config) override; int Run(TConfig& config) override; }; diff --git a/ydb/core/driver_lib/cli_utils/cli.h b/ydb/core/driver_lib/cli_utils/cli.h index 550f6835e7a..02fc9b40fe6 100644 --- a/ydb/core/driver_lib/cli_utils/cli.h +++ b/ydb/core/driver_lib/cli_utils/cli.h @@ -41,6 +41,6 @@ namespace NDriverClient { void HideOptions(NLastGetopt::TOpts& opts, const TString& prefix); void HideOptions(NLastGetopt::TOpts& opts); int NewClient(int argc, char** argv, std::shared_ptr<TModuleFactories> factories); - TString NewClientCommandsDescription(std::shared_ptr<TModuleFactories> factories); + TString NewClientCommandsDescription(const TString& name, std::shared_ptr<TModuleFactories> factories); } } diff --git a/ydb/core/driver_lib/cli_utils/cli_cmds_root.cpp b/ydb/core/driver_lib/cli_utils/cli_cmds_root.cpp index ec049fab114..802557cc942 100644 --- a/ydb/core/driver_lib/cli_utils/cli_cmds_root.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_cmds_root.cpp @@ -6,6 +6,8 @@ #include <util/string/strip.h> #include <util/system/env.h> +#include <filesystem> + namespace NKikimr { namespace NDriverClient { @@ -15,8 +17,8 @@ extern void AddClientCommandServer(TClientCommandTree& parent, std::shared_ptr<T class TClientCommandRoot : public TClientCommandRootKikimrBase { public: - TClientCommandRoot(std::shared_ptr<TModuleFactories> factories) - : TClientCommandRootKikimrBase("kikimr") + TClientCommandRoot(const TString& name, std::shared_ptr<TModuleFactories> factories) + : TClientCommandRootKikimrBase(name) { AddCommand(std::make_unique<TClientCommandAdmin>()); AddCommand(std::make_unique<TClientCommandDb>()); @@ -80,14 +82,14 @@ private: }; int NewClient(int argc, char** argv, std::shared_ptr<TModuleFactories> factories) { - THolder<TClientCommandRoot> commandsRoot = MakeHolder<TClientCommandRoot>(std::move(factories)); + auto commandsRoot = MakeHolder<TClientCommandRoot>(std::filesystem::path(argv[0]).stem().string(), std::move(factories)); TClientCommand::TConfig config(argc, argv); // TODO: process flags from environment KIKIMR_FLAGS before command line processing return commandsRoot->Process(config); } -TString NewClientCommandsDescription(std::shared_ptr<TModuleFactories> factories) { - THolder<TClientCommandRoot> commandsRoot = MakeHolder<TClientCommandRoot>(std::move(factories)); +TString NewClientCommandsDescription(const TString& name, std::shared_ptr<TModuleFactories> factories) { + THolder<TClientCommandRoot> commandsRoot = MakeHolder<TClientCommandRoot>(name, std::move(factories)); TStringStream stream; NColorizer::TColors colors = NColorizer::AutoColors(Cout); stream << " [options] <subcommand>" << Endl << Endl diff --git a/ydb/core/driver_lib/run/main.cpp b/ydb/core/driver_lib/run/main.cpp index d3b4803fecd..907bedbca02 100644 --- a/ydb/core/driver_lib/run/main.cpp +++ b/ydb/core/driver_lib/run/main.cpp @@ -21,6 +21,8 @@ #include <sys/mman.h> #endif +#include <filesystem> + namespace NKikimr { int MainRun(const TKikimrRunConfig& runConfig, std::shared_ptr<TModuleFactories> factories) { @@ -82,7 +84,7 @@ int MainRun(const TKikimrRunConfig& runConfig, std::shared_ptr<TModuleFactories> .NoArgument().Handler(&PrintAllocatorInfoAndExit); opts.SetFreeArgsMin(1); opts.SetFreeArgTitle(0, "<command>", TDriverModeParser::CommandsCsv()); - opts.SetCmdLineDescr(NDriverClient::NewClientCommandsDescription(factories)); + opts.SetCmdLineDescr(NDriverClient::NewClientCommandsDescription(std::filesystem::path(argv[0]).stem().string(), factories)); opts.AddHelpOption('h'); opts.ArgPermutation_ = NLastGetopt::REQUIRE_ORDER; diff --git a/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp b/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp index d8f7425cfe1..2acdfd1f668 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp @@ -23,8 +23,8 @@ namespace NYdb { namespace NConsoleClient { -TClientCommandRootCommon::TClientCommandRootCommon(const TClientSettings& settings) - : TClientCommandRootBase("ydb") +TClientCommandRootCommon::TClientCommandRootCommon(const TString& name, const TClientSettings& settings) + : TClientCommandRootBase(name) , Settings (settings) { ValidateSettings(); diff --git a/ydb/public/lib/ydb_cli/commands/ydb_root_common.h b/ydb/public/lib/ydb_cli/commands/ydb_root_common.h index 0acf12f406e..0449516607c 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_root_common.h +++ b/ydb/public/lib/ydb_cli/commands/ydb_root_common.h @@ -27,7 +27,7 @@ struct TClientSettings { class TClientCommandRootCommon : public TClientCommandRootBase { public: - TClientCommandRootCommon(const TClientSettings& settings); + TClientCommandRootCommon(const TString& name, const TClientSettings& settings); void Config(TConfig& config) override; void Parse(TConfig& config) override; void ParseAddress(TConfig& config) override; |