-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'only_save_successful_commands_in_history' into 'master'
Only save successful commands in the history file See merge request npneq/inq!1091
- Loading branch information
Showing
4 changed files
with
95 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* -*- indent-tabs-mode: t -*- */ | ||
|
||
#ifndef INQ__INTERFACE__HISTORY_FILE | ||
#define INQ__INTERFACE__HISTORY_FILE | ||
|
||
// Copyright (C) 2019-2024 Lawrence Livermore National Security, LLC., Xavier Andrade, Alfredo A. Correa | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
namespace inq { | ||
namespace interface { | ||
|
||
struct { | ||
|
||
std::string entries_; | ||
|
||
public: | ||
|
||
void add_entry(int argc, char ** argv) { | ||
|
||
for(int iarg = 0; iarg < argc; iarg++) { | ||
auto arg = std::string(argv[iarg]); | ||
auto & npos = std::string::npos; | ||
if(arg.find(' ') != npos or arg.find('(') != npos or arg.find(')') != npos){ | ||
arg = '\"' + arg + '\"'; | ||
} | ||
if(iarg > 0) entries_ += ' '; | ||
entries_ += arg; | ||
} | ||
entries_ += '\n'; | ||
} | ||
|
||
void write() const { | ||
auto history_file = std::ofstream(".inq_history", std::ofstream::app); | ||
history_file << entries_; | ||
} | ||
|
||
} history_file; | ||
|
||
} | ||
} | ||
|
||
#endif | ||
|
||
#ifdef INQ_INTERFACE_HISTORY_FILE_UNIT_TEST | ||
#undef INQ_INTERFACE_HISTORY_FILE_UNIT_TEST | ||
|
||
#include <catch2/catch_all.hpp> | ||
|
||
TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG) { | ||
|
||
using namespace inq; | ||
using namespace Catch::literals; | ||
|
||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters