mirror of
https://github.com/google/sentencepiece.git
synced 2024-12-28 02:34:25 +03:00
makes the return value of --help same as official abseil library
This commit is contained in:
parent
52a7f156a4
commit
725952d8b8
@ -18,6 +18,7 @@
|
||||
#include "common.h"
|
||||
#include "third_party/absl/flags/flag.h"
|
||||
#include "third_party/absl/flags/parse.h"
|
||||
#include "third_party/absl/flags/usage.h"
|
||||
|
||||
#ifdef _USE_EXTERNAL_PROTOBUF
|
||||
#include "google/protobuf/message_lite.h"
|
||||
@ -30,6 +31,7 @@ ABSL_DECLARE_FLAG(int32, minloglevel);
|
||||
namespace sentencepiece {
|
||||
inline void ParseCommandLineFlags(const char *usage, int *argc, char ***argv,
|
||||
bool remove_arg = true) {
|
||||
absl::SetProgramUsageMessage(*argv[0]);
|
||||
const auto unused_args = absl::ParseCommandLine(*argc, *argv);
|
||||
|
||||
if (remove_arg) {
|
||||
|
2
third_party/absl/flags/flag.cc
vendored
2
third_party/absl/flags/flag.cc
vendored
@ -211,7 +211,7 @@ std::vector<char *> ParseCommandLine(int argc, char *argv[]) {
|
||||
|
||||
if (absl::GetFlag(FLAGS_help)) {
|
||||
std::cout << internal::PrintHelp(argv[0]);
|
||||
sentencepiece::error::Exit(0);
|
||||
sentencepiece::error::Exit(1);
|
||||
} else if (absl::GetFlag(FLAGS_version)) {
|
||||
std::cout << PACKAGE_STRING << " " << VERSION << std::endl;
|
||||
sentencepiece::error::Exit(0);
|
||||
|
28
third_party/absl/flags/usage.h
vendored
Normal file
28
third_party/absl/flags/usage.h
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2016 Google Inc.
|
||||
//
|
||||
// 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.!
|
||||
|
||||
#ifndef ABSL_FLAGS_USAGE_H_
|
||||
#define ABSL_FLAGS_USAGE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "third_party/absl/strings/string_view.h"
|
||||
|
||||
namespace absl {
|
||||
|
||||
inline void SetProgramUsageMessage(absl::string_view new_usage_message) {}
|
||||
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_FLAGS_USAGE_H_
|
Loading…
Reference in New Issue
Block a user