mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-01-30 16:45:35 +02:00
Switch asset_stream_manager to use Lyra Lyra has a nice simple interface, but a few quirks that we work around, mainly in the BaseCommand class: - It does not support return values from running a command. - It does not support return values from a custom arg parser. - Lyra interprets --bad_arg as positional argument. Fixes #15
44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
// Copyright 2022 Google LLC
|
|
//
|
|
// 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.
|
|
|
|
#include "asset_stream_manager/start_service_command.h"
|
|
#include "lyra/lyra.hpp"
|
|
|
|
int main(int argc, char* argv[]) {
|
|
// Set up commands.
|
|
auto cli = lyra::cli();
|
|
bool show_help = false;
|
|
int exit_code = -1;
|
|
cli.add_argument(lyra::help(show_help));
|
|
|
|
cdc_ft::StartServiceCommand start_service(&exit_code);
|
|
start_service.Register(cli);
|
|
|
|
// Parse args and run. Note that parse actually runs the commands.
|
|
// exit_code is -1 if no command was run.
|
|
auto result = cli.parse({argc, argv});
|
|
if (show_help || exit_code == -1) {
|
|
std::cout << cli;
|
|
return 0;
|
|
}
|
|
if (!result) {
|
|
// Parse error.
|
|
std::cerr << "Error: " << result.message() << std::endl;
|
|
return 1;
|
|
}
|
|
// If cli.parse() succeeds, it also runs the commands and writes |exit_code|.
|
|
|
|
return exit_code;
|
|
}
|