blob: ba4ca68b0e5cc719e720eaabf274f9aea16164f4 [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <lib/cmdline/args_parser.h>
#include <iostream>
#include <string>
#include "src/lib/analytics/cpp/core_dev_tools/analytics_status.h"
namespace analytics::core_dev_tools {
enum class AnalyticsOption { kEnable, kDisable, kSubLaunchFirst, kSubLaunchNormal, kUnspecified };
extern const char* const kAnalyticsHelp;
extern const char* const kAnalyticsShowHelp;
cmdline::Status ParseAnalyticsOption(const std::string& value, AnalyticsOption& analytics_option);
// Early processing of analytics options. Returns true if invoked with --analytics=enable|disable or
// --show-analytics, indicating that we are expected to exit after analytics related actions.
// T is the Analytics class for the tool.
template <class T>
bool EarlyProcessAnalyticsOptions(AnalyticsOption analytics_option, bool analytics_show) {
bool should_exit_early = false;
if (analytics_option == AnalyticsOption::kEnable) {
should_exit_early = true;
} else if (analytics_option == AnalyticsOption::kDisable) {
should_exit_early = true;
if (analytics_show) {
should_exit_early = true;
return should_exit_early;
std::istream& operator>>(std::istream& is, AnalyticsOption& analytics_option);
} // namespace analytics::core_dev_tools