Skip to content

Commit

Permalink
Scaffold an executable
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidokert committed Aug 9, 2024
1 parent a075f8b commit 6aea7ed
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
10 changes: 10 additions & 0 deletions net/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,16 @@ static_library("test_support") {
}
}

target(final_executable_type, "downloader") {
testonly = true
sources = [
"tools/downloader/downloader.cc"
]
deps = [
":net",
]
}

if (!is_ios && !is_android && !use_cobalt_customizations) {
executable("cert_verify_tool") {
testonly = true
Expand Down
43 changes: 43 additions & 0 deletions net/tools/downloader/downloader.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <iostream>
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/task/single_thread_task_executor.h"


namespace downloader {
void PrintUsage(std::ostream* stream) {
*stream << "Usage: downloader <url>" << std::endl;
}

bool Main(int argc, char** argv) {
base::AtExitManager at_exit_manager;

logging::LoggingSettings settings;
settings.logging_dest =
logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;
logging::InitLogging(settings);

base::CommandLine::Init(argc, argv);
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch("help")) {
PrintUsage(&std::cout);
return true;
}
if (command_line.HasSwitch("url")) {
std::string url = command_line.GetSwitchValueASCII("url");
LOG(ERROR) << "URL URL :" << url;
}

// Just make the main task executor the network loop.
base::SingleThreadTaskExecutor io_task_executor(base::MessagePumpType::IO);


LOG(ERROR) << "Hey";
}
} // namespace downloader

int main(int argc, char** argv) {
return !downloader::Main(argc, argv);
}

0 comments on commit 6aea7ed

Please sign in to comment.