Skip to content

Commit 385c77d

Browse files
committed
Remove the cvd_common::[Args,Envs] aliases.
https://google.github.io/styleguide/cppguide.html#Aliases writes > Don't put an alias in your public API just to save typing in the implementation; do so only if you intend it to be used by your clients. > When defining a public alias, document the intent of the new name, including whether it is guaranteed to always be the same as the type it's currently aliased to, or whether a more limited compatibility is intended. This lets the user know whether they can treat the types as substitutable or whether more specific rules must be followed, and can help the implementation retain some degree of freedom to change the alias. These aliases were defined without documentation, and most of the API of the underlying types was being used. This change replaces uses of the aliases with their referenced types. Bug: b/533168205
1 parent ed0dd19 commit 385c77d

83 files changed

Lines changed: 255 additions & 320 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/cvd/cuttlefish/host/commands/cvd/cli/BUILD.bazel

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ cf_cc_library(
99
srcs = ["command_request.cpp"],
1010
hdrs = ["command_request.h"],
1111
deps = [
12-
":types",
1312
"//cuttlefish/flag_parser",
1413
"//cuttlefish/host/commands/cvd/cli/selector:selector_common_parser",
1514
"//cuttlefish/result",
@@ -22,7 +21,6 @@ cf_cc_library(
2221
srcs = ["frontline_parser.cpp"],
2322
hdrs = ["frontline_parser.h"],
2423
deps = [
25-
":types",
2624
"//cuttlefish/flag_parser",
2725
"//cuttlefish/host/commands/cvd/cli/selector:selector_common_parser",
2826
"//cuttlefish/result",
@@ -114,7 +112,6 @@ cf_cc_library(
114112
"//cuttlefish/flag_parser",
115113
"//cuttlefish/host/commands/cvd/cli:command_request",
116114
"//cuttlefish/host/commands/cvd/cli:help_format",
117-
"//cuttlefish/host/commands/cvd/cli:types",
118115
"//cuttlefish/host/commands/cvd/cli:utils",
119116
"//cuttlefish/host/commands/cvd/cli/commands:bugreport",
120117
"//cuttlefish/host/commands/cvd/cli/commands:cache",
@@ -168,18 +165,13 @@ cf_cc_library(
168165
],
169166
)
170167

171-
cf_cc_library(
172-
name = "types",
173-
hdrs = ["types.h"],
174-
)
175-
176168
cf_cc_library(
177169
name = "utils",
178170
srcs = ["utils.cpp"],
179171
hdrs = ["utils.h"],
180172
deps = [
181173
":command_request",
182-
":types",
174+
"//cuttlefish/ansi_codes",
183175
"//cuttlefish/ansi_codes:terminal_colors",
184176
"//cuttlefish/common/libs/fs",
185177
"//cuttlefish/common/libs/utils:contains",

base/cvd/cuttlefish/host/commands/cvd/cli/command_request.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ constexpr std::array help_str_opts{
4646
};
4747

4848
} // namespace
49-
CommandRequest::CommandRequest(cvd_common::Args args, cvd_common::Envs env,
49+
CommandRequest::CommandRequest(std::vector<std::string> args,
50+
std::unordered_map<std::string, std::string> env,
5051
selector::SelectorOptions selectors)
5152
: args_(std::move(args)),
5253
env_(std::move(env)),
@@ -82,12 +83,14 @@ CommandRequestBuilder CommandRequestBuilder::AddArguments(
8283
return AddArguments(std::vector<std::string_view>(args));
8384
}
8485

85-
CommandRequestBuilder& CommandRequestBuilder::SetEnv(cvd_common::Envs env) & {
86+
CommandRequestBuilder& CommandRequestBuilder::SetEnv(
87+
std::unordered_map<std::string, std::string> env) & {
8688
env_ = std::move(env);
8789
return *this;
8890
}
8991

90-
CommandRequestBuilder CommandRequestBuilder::SetEnv(cvd_common::Envs env) && {
92+
CommandRequestBuilder CommandRequestBuilder::SetEnv(
93+
std::unordered_map<std::string, std::string> env) && {
9194
env_ = std::move(env);
9295
return *this;
9396
}

base/cvd/cuttlefish/host/commands/cvd/cli/command_request.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525
#include <vector>
2626

2727
#include "cuttlefish/host/commands/cvd/cli/selector/selector_common_parser.h"
28-
#include "cuttlefish/host/commands/cvd/cli/types.h"
2928
#include "cuttlefish/result/result.h"
3029

3130
namespace cuttlefish {
3231

3332
class CommandRequest {
3433
public:
35-
const cvd_common::Envs& Env() const { return env_; }
34+
const std::unordered_map<std::string, std::string>& Env() const {
35+
return env_;
36+
}
3637

3738
const selector::SelectorOptions& Selectors() const { return selectors_; }
3839

@@ -43,11 +44,12 @@ class CommandRequest {
4344

4445
private:
4546
friend class CommandRequestBuilder;
46-
CommandRequest(cvd_common::Args args, cvd_common::Envs env,
47+
CommandRequest(std::vector<std::string> args,
48+
std::unordered_map<std::string, std::string> env,
4749
selector::SelectorOptions selectors);
4850

49-
cvd_common::Args args_;
50-
cvd_common::Envs env_;
51+
std::vector<std::string> args_;
52+
std::unordered_map<std::string, std::string> env_;
5153
selector::SelectorOptions selectors_;
5254

5355
std::string subcommand_;
@@ -91,17 +93,17 @@ class CommandRequestBuilder {
9193
return *this;
9294
}
9395

94-
CommandRequestBuilder& SetEnv(cvd_common::Envs) &;
95-
CommandRequestBuilder SetEnv(cvd_common::Envs) &&;
96+
CommandRequestBuilder& SetEnv(std::unordered_map<std::string, std::string>) &;
97+
CommandRequestBuilder SetEnv(std::unordered_map<std::string, std::string>) &&;
9698

9799
CommandRequestBuilder& AddEnvVar(std::string key, std::string val) &;
98100
CommandRequestBuilder AddEnvVar(std::string key, std::string val) &&;
99101

100102
Result<CommandRequest> Build() &&;
101103

102104
private:
103-
cvd_common::Args args_;
104-
cvd_common::Envs env_;
105+
std::vector<std::string> args_;
106+
std::unordered_map<std::string, std::string> env_;
105107
selector::SelectorOptions selector_options_;
106108
};
107109

base/cvd/cuttlefish/host/commands/cvd/cli/commands/BUILD.bazel

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ cf_cc_library(
2626
"//cuttlefish/flag_parser",
2727
"//cuttlefish/host/commands/cvd/cli:command_request",
2828
"//cuttlefish/host/commands/cvd/cli:interruptible_terminal",
29-
"//cuttlefish/host/commands/cvd/cli:types",
3029
"//cuttlefish/host/commands/cvd/cli:utils",
3130
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
3231
"//cuttlefish/host/commands/cvd/cli/selector",
@@ -52,7 +51,6 @@ cf_cc_library(
5251
"//cuttlefish/flag_parser",
5352
"//cuttlefish/host/commands/cvd/cache",
5453
"//cuttlefish/host/commands/cvd/cli:command_request",
55-
"//cuttlefish/host/commands/cvd/cli:types",
5654
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
5755
"//cuttlefish/host/commands/cvd/utils",
5856
"//cuttlefish/result",
@@ -69,7 +67,6 @@ cf_cc_library(
6967
deps = [
7068
"//cuttlefish/flag_parser",
7169
"//cuttlefish/host/commands/cvd/cli:command_request",
72-
"//cuttlefish/host/commands/cvd/cli:types",
7370
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
7471
"//cuttlefish/host/commands/cvd/instances",
7572
"//cuttlefish/host/commands/cvd/instances:instance_manager",
@@ -85,7 +82,6 @@ cf_cc_library(
8582
"//cuttlefish/flag_parser",
8683
"//cuttlefish/host/commands/cvd/cli:command_request",
8784
"//cuttlefish/host/commands/cvd/cli:help_format",
88-
"//cuttlefish/host/commands/cvd/cli:types",
8985
"//cuttlefish/host/commands/cvd/cli/selector:selector_common_parser",
9086
"//cuttlefish/result",
9187
],
@@ -100,7 +96,6 @@ cf_cc_library(
10096
"//cuttlefish/common/libs/utils:subprocess",
10197
"//cuttlefish/flag_parser",
10298
"//cuttlefish/host/commands/cvd/cli:command_request",
103-
"//cuttlefish/host/commands/cvd/cli:types",
10499
"//cuttlefish/host/commands/cvd/cli:utils",
105100
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
106101
"//cuttlefish/host/commands/cvd/cli/selector",
@@ -121,7 +116,6 @@ cf_cc_library(
121116
"//cuttlefish/common/libs/utils:subprocess_managed_stdio",
122117
"//cuttlefish/flag_parser",
123118
"//cuttlefish/host/commands/cvd/cli:command_request",
124-
"//cuttlefish/host/commands/cvd/cli:types",
125119
"//cuttlefish/host/commands/cvd/cli:utils",
126120
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
127121
"//cuttlefish/host/commands/cvd/cli/selector",
@@ -144,7 +138,6 @@ cf_cc_library(
144138
"//cuttlefish/common/libs/utils:tee_logging",
145139
"//cuttlefish/host/commands/cvd/cache",
146140
"//cuttlefish/host/commands/cvd/cli:command_request",
147-
"//cuttlefish/host/commands/cvd/cli:types",
148141
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
149142
"//cuttlefish/host/commands/cvd/fetch:auto_login",
150143
"//cuttlefish/host/commands/cvd/fetch:build_api_flags",
@@ -167,7 +160,6 @@ cf_cc_library(
167160
deps = [
168161
"//cuttlefish/flag_parser",
169162
"//cuttlefish/host/commands/cvd/cli:command_request",
170-
"//cuttlefish/host/commands/cvd/cli:types",
171163
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
172164
"//cuttlefish/host/commands/cvd/instances",
173165
"//cuttlefish/host/commands/cvd/instances:instance_manager",
@@ -184,7 +176,6 @@ cf_cc_library(
184176
deps = [
185177
"//cuttlefish/flag_parser",
186178
"//cuttlefish/host/commands/cvd/cli:command_request",
187-
"//cuttlefish/host/commands/cvd/cli:types",
188179
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
189180
"//cuttlefish/host/commands/cvd/instances",
190181
"//cuttlefish/host/commands/cvd/instances:instance_manager",
@@ -217,7 +208,6 @@ cf_cc_library(
217208
deps = [
218209
"//cuttlefish/flag_parser",
219210
"//cuttlefish/host/commands/cvd/cli:command_request",
220-
"//cuttlefish/host/commands/cvd/cli:types",
221211
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
222212
"//cuttlefish/host/commands/cvd/cli/parser:load_configs_parser",
223213
"//cuttlefish/result",
@@ -233,7 +223,6 @@ cf_cc_library(
233223
"//cuttlefish/common/libs/utils:is_google_corp",
234224
"//cuttlefish/flag_parser",
235225
"//cuttlefish/host/commands/cvd/cli:command_request",
236-
"//cuttlefish/host/commands/cvd/cli:types",
237226
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
238227
"//cuttlefish/host/libs/web:oauth2_consent",
239228
"//cuttlefish/host/libs/web/http_client",
@@ -255,7 +244,6 @@ cf_cc_library(
255244
"//cuttlefish/flag_parser",
256245
"//cuttlefish/host/commands/cvd/cli:command_request",
257246
"//cuttlefish/host/commands/cvd/cli:help_format",
258-
"//cuttlefish/host/commands/cvd/cli:types",
259247
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
260248
"//cuttlefish/host/commands/cvd/cli/selector",
261249
"//cuttlefish/host/commands/cvd/instances",
@@ -273,7 +261,6 @@ cf_cc_library(
273261
deps = [
274262
"//cuttlefish/flag_parser",
275263
"//cuttlefish/host/commands/cvd/cli:command_request",
276-
"//cuttlefish/host/commands/cvd/cli:types",
277264
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
278265
"//cuttlefish/host/commands/cvd/cli/selector",
279266
"//cuttlefish/host/commands/cvd/instances",
@@ -291,7 +278,6 @@ cf_cc_library(
291278
deps = [
292279
"//cuttlefish/flag_parser",
293280
"//cuttlefish/host/commands/cvd/cli:command_request",
294-
"//cuttlefish/host/commands/cvd/cli:types",
295281
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
296282
"//cuttlefish/host/commands/cvd/cli/selector",
297283
"//cuttlefish/host/commands/cvd/instances",
@@ -310,7 +296,6 @@ cf_cc_library(
310296
"//cuttlefish/flag_parser",
311297
"//cuttlefish/host/commands/cvd/cli:command_request",
312298
"//cuttlefish/host/commands/cvd/cli:help_format",
313-
"//cuttlefish/host/commands/cvd/cli:types",
314299
"//cuttlefish/host/commands/cvd/cli:utils",
315300
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
316301
"//cuttlefish/host/commands/cvd/cli/selector",
@@ -331,7 +316,6 @@ cf_cc_library(
331316
"//cuttlefish/flag_parser",
332317
"//cuttlefish/host/commands/cvd/cli:command_request",
333318
"//cuttlefish/host/commands/cvd/cli:help_format",
334-
"//cuttlefish/host/commands/cvd/cli:types",
335319
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
336320
"//cuttlefish/host/commands/cvd/instances",
337321
"//cuttlefish/host/commands/cvd/instances:instance_manager",
@@ -349,7 +333,6 @@ cf_cc_library(
349333
deps = [
350334
"//cuttlefish/flag_parser",
351335
"//cuttlefish/host/commands/cvd/cli:command_request",
352-
"//cuttlefish/host/commands/cvd/cli:types",
353336
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
354337
"//cuttlefish/host/commands/cvd/cli/selector",
355338
"//cuttlefish/host/commands/cvd/instances",
@@ -367,7 +350,6 @@ cf_cc_library(
367350
deps = [
368351
"//cuttlefish/flag_parser",
369352
"//cuttlefish/host/commands/cvd/cli:command_request",
370-
"//cuttlefish/host/commands/cvd/cli:types",
371353
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
372354
"//cuttlefish/host/commands/cvd/cli/selector",
373355
"//cuttlefish/host/commands/cvd/instances",
@@ -388,7 +370,6 @@ cf_cc_library(
388370
"//cuttlefish/common/libs/utils:files",
389371
"//cuttlefish/common/libs/utils:subprocess",
390372
"//cuttlefish/host/commands/cvd/cli:command_request",
391-
"//cuttlefish/host/commands/cvd/cli:types",
392373
"//cuttlefish/host/commands/cvd/cli:utils",
393374
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
394375
"//cuttlefish/host/commands/cvd/cli/commands:host_tool_target",
@@ -417,7 +398,6 @@ cf_cc_library(
417398
"//cuttlefish/flag_parser",
418399
"//cuttlefish/host/commands/cvd/cli:command_request",
419400
"//cuttlefish/host/commands/cvd/cli:help_format",
420-
"//cuttlefish/host/commands/cvd/cli:types",
421401
"//cuttlefish/host/commands/cvd/cli:utils",
422402
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
423403
"//cuttlefish/host/commands/cvd/cli/commands:host_tool_target",
@@ -450,7 +430,6 @@ cf_cc_library(
450430
deps = [
451431
"//cuttlefish/flag_parser",
452432
"//cuttlefish/host/commands/cvd/cli:command_request",
453-
"//cuttlefish/host/commands/cvd/cli:types",
454433
"//cuttlefish/host/commands/cvd/cli:utils",
455434
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
456435
"//cuttlefish/host/commands/cvd/cli/selector",
@@ -473,7 +452,6 @@ cf_cc_library(
473452
"//cuttlefish/flag_parser",
474453
"//cuttlefish/host/commands/cvd/cli:command_request",
475454
"//cuttlefish/host/commands/cvd/cli:help_format",
476-
"//cuttlefish/host/commands/cvd/cli:types",
477455
"//cuttlefish/host/commands/cvd/cli:utils",
478456
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
479457
"//cuttlefish/host/commands/cvd/cli/commands:host_tool_target",
@@ -496,7 +474,6 @@ cf_cc_library(
496474
"//cuttlefish/common/libs/utils:proto",
497475
"//cuttlefish/flag_parser",
498476
"//cuttlefish/host/commands/cvd/cli:command_request",
499-
"//cuttlefish/host/commands/cvd/cli:types",
500477
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
501478
"//cuttlefish/host/commands/cvd/utils",
502479
"//cuttlefish/host/commands/cvd/version",
@@ -514,7 +491,6 @@ cf_cc_library(
514491
"//cuttlefish/common/libs/utils:subprocess",
515492
"//cuttlefish/host/commands/cvd/cli:command_request",
516493
"//cuttlefish/host/commands/cvd/cli:help_format",
517-
"//cuttlefish/host/commands/cvd/cli:types",
518494
"//cuttlefish/host/commands/cvd/cli/commands:command_handler",
519495
"//cuttlefish/host/libs/vm_manager",
520496
"//cuttlefish/result",

base/cvd/cuttlefish/host/commands/cvd/cli/commands/bugreport.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <iostream>
2222
#include <string>
23+
#include <unordered_map>
2324
#include <utility>
2425
#include <vector>
2526

@@ -35,7 +36,6 @@
3536
#include "cuttlefish/flag_parser/gflags_compat.h"
3637
#include "cuttlefish/host/commands/cvd/cli/command_request.h"
3738
#include "cuttlefish/host/commands/cvd/cli/selector/selector.h"
38-
#include "cuttlefish/host/commands/cvd/cli/types.h"
3939
#include "cuttlefish/host/commands/cvd/cli/utils.h"
4040
#include "cuttlefish/host/commands/cvd/instances/instance_manager.h"
4141
#include "cuttlefish/host/commands/cvd/instances/local_instance_group.h"
@@ -53,7 +53,7 @@ constexpr char kSummaryHelpText[] =
5353
"Run cvd bugreport --help for command description";
5454

5555
// Accepts a copy of the args to not modify the original.
56-
Result<std::string> OutputFileFromArgs(cvd_common::Args args) {
56+
Result<std::string> OutputFileFromArgs(std::vector<std::string> args) {
5757
// This flag must match the one defined in
5858
// //cuttlefish/host/commands/host_bugreport/main.cc
5959
std::string output = "host_bugreport.zip";
@@ -93,7 +93,7 @@ CvdBugreportCommandHandler::CvdBugreportCommandHandler(
9393

9494
Result<void> CvdBugreportCommandHandler::Handle(const CommandRequest& request) {
9595
std::vector<std::string> cmd_args = request.SubcommandArguments();
96-
cvd_common::Envs env = request.Env();
96+
std::unordered_map<std::string, std::string> env = request.Env();
9797

9898
std::string output_file =
9999
CF_EXPECT(OutputFileFromArgs(cmd_args), "Failed to parse output flag");

base/cvd/cuttlefish/host/commands/cvd/cli/commands/bugreport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CvdBugreportCommandHandler : public CvdCommandHandler {
2929
CvdBugreportCommandHandler(InstanceManager& instance_manager);
3030

3131
Result<void> Handle(const CommandRequest& request) override;
32-
cvd_common::Args CmdList() const override;
32+
std::vector<std::string> CmdList() const override;
3333
std::string SummaryHelp() const override;
3434

3535
bool RequiresDeviceExists() const override;

base/cvd/cuttlefish/host/commands/cvd/cli/commands/cache.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "cuttlefish/flag_parser/gflags_compat.h"
3333
#include "cuttlefish/host/commands/cvd/cache/cache.h"
3434
#include "cuttlefish/host/commands/cvd/cli/command_request.h"
35-
#include "cuttlefish/host/commands/cvd/cli/types.h"
3635
#include "cuttlefish/host/commands/cvd/utils/common.h"
3736
#include "cuttlefish/result/result.h"
3837

@@ -139,7 +138,9 @@ Result<void> CvdCacheCommandHandler::Handle(const CommandRequest& request) {
139138
return {};
140139
}
141140

142-
cvd_common::Args CvdCacheCommandHandler::CmdList() const { return {"cache"}; }
141+
std::vector<std::string> CvdCacheCommandHandler::CmdList() const {
142+
return {"cache"};
143+
}
143144

144145
std::string CvdCacheCommandHandler::SummaryHelp() const {
145146
return kSummaryHelpText;

base/cvd/cuttlefish/host/commands/cvd/cli/commands/cache.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <string>
2020

2121
#include "cuttlefish/host/commands/cvd/cli/commands/command_handler.h"
22-
#include "cuttlefish/host/commands/cvd/cli/types.h"
2322
#include "cuttlefish/result/result.h"
2423

2524
namespace cuttlefish {
@@ -28,7 +27,7 @@ class CvdCacheCommandHandler : public CvdCommandHandler {
2827
public:
2928
Result<void> Handle(const CommandRequest& request) override;
3029

31-
cvd_common::Args CmdList() const override;
30+
std::vector<std::string> CmdList() const override;
3231

3332
std::string SummaryHelp() const override;
3433
Result<std::string> DetailedHelp(const CommandRequest& request) override;

0 commit comments

Comments
 (0)