Skip to content

Commit

Permalink
PD-5076 na -> NA
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyacheslav Brover committed Aug 5, 2024
1 parent 38b86b4 commit 62b3d0c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 42 deletions.
42 changes: 21 additions & 21 deletions common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3689,14 +3689,11 @@ string Application::key2shortHelp (const string &name) const



string Application::getInstruction (bool coutP) const
string Application::getInstruction (bool screen) const
{
string instr (description);

if (isRedirected (cout))
coutP = false;

instr += "\n\n" + colorize ("USAGE", coutP) + ": " + programName;
instr += "\n\n" + colorize ("USAGE", screen) + ": " + programName;

for (const Positional& p : positionalArgs)
instr += " " + p. str ();
Expand Down Expand Up @@ -3728,10 +3725,10 @@ string Application::getInstruction (bool coutP) const
if (! requiredGroup_prev. empty ())
instr += ")";

instr += "\n" + colorize ("HELP", coutP) + ": " + programName + " " + ifS (gnu, "-") + "-" + helpS;
instr += "\n" + colorize ("HELP", screen) + ": " + programName + " " + ifS (gnu, "-") + "-" + helpS;
if (gnu)
instr += " or " + programName + " -" + helpS [0];
instr += "\n" + colorize ("VERSION", coutP) + ": " + programName + " " + ifS (gnu, "-") + "-" + versionS;
instr += "\n" + colorize ("VERSION", screen) + ": " + programName + " " + ifS (gnu, "-") + "-" + versionS;
if (gnu)
instr += " or " + programName + " -" + versionS [0];

Expand All @@ -3740,42 +3737,43 @@ string Application::getInstruction (bool coutP) const



string Application::getDocumentation () const
string Application::getDocumentation (bool screen) const
{
if (documentationUrl. empty ())
return noString;
return "\n\n" + colorize ("DOCUMENTATION", true) + "\n See " + documentationUrl + " for full documentation";
return "\n\n" + colorize ("DOCUMENTATION", screen) + "\n See " + colorizeUrl (documentationUrl, screen) + " for full documentation";
}



string Application::getUpdates () const
string Application::getUpdates (bool screen) const
{
if (updatesDoc. empty ())
return noString;
return "\n\n" + colorize ("UPDATES", true) + "\n" + updatesDoc;
string s ("\n\n" + colorize ("UPDATES", screen) + "\n" + updatesDoc);
if (! updatesUrl. empty ())
s += ": " + colorizeUrl (updatesUrl, screen);
return s;
}



string Application::getHelp () const
string Application::getHelp (bool screen) const
{
string instr (getInstruction (true));
string instr (getInstruction (screen));

const string par ("\n ");

const bool coutP = ! isRedirected (cout);

if (! positionalArgs. empty ())
{
instr += "\n\n" + colorize ("POSITIONAL PARAMETERS", coutP) /*+ ":"*/;
instr += "\n\n" + colorize ("POSITIONAL PARAMETERS", screen) /*+ ":"*/;
for (const Positional& p : positionalArgs)
instr += "\n" + p. str () + par + p. description;
}

if (! keyArgs. empty ())
{
instr += "\n\n" + colorize ("NAMED PARAMETERS", coutP) /*+ ":"*/;
instr += "\n\n" + colorize ("NAMED PARAMETERS", screen) /*+ ":"*/;
for (const Key& key : keyArgs)
{
instr += "\n" + key. getShortHelp () + par + key. description;
Expand Down Expand Up @@ -3875,7 +3873,8 @@ int Application::run (int argc,

if (name == helpS || (name. empty () && c == helpS [0] && gnu))
{
cout << getHelp () << getDocumentation () << getUpdates () << endl;
const bool screen = ! isRedirected (cout);
cout << getHelp (screen) << getDocumentation (screen) << getUpdates (screen) << endl;
return 0;
}
if (name == versionS || (name. empty () && c == versionS [0] && gnu))
Expand Down Expand Up @@ -3921,7 +3920,8 @@ int Application::run (int argc,

if (programArgs. size () == 1 && (! positionalArgs. empty () || needsArg))
{
cout << getInstruction (true) << getDocumentation () << endl;
const bool screen = ! isRedirected (cout);
cout << getInstruction (screen) << getDocumentation (screen) << endl;
return 1;
}

Expand Down Expand Up @@ -4142,9 +4142,9 @@ void ShellApplication::initVar ()



string ShellApplication::getHelp () const
string ShellApplication::getHelp (bool screen) const
{
string help (Application::getHelp ());
string help (Application::getHelp (screen));
if (useTmp)
help += "\n\nTemporary directory used is $TMPDIR or \"/tmp\"";
return help;
Expand Down
45 changes: 26 additions & 19 deletions common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1481,20 +1481,21 @@ struct Color
};


inline string colorize (const string &s,
bool active)
{ if (! active)
inline string colorize_raw (const string &s,
Color::Type color,
bool screen)
{ if (! screen)
return s;
return Color::code (Color::white, true) + s + Color::code ();
return Color::code (color, true) + s + Color::code ();
}

inline string colorize (const string &s,
bool screen)
{ return colorize_raw (s, Color::white, screen); }

inline string colorizeUrl (const string &s,
bool active)
{ const string prefix ("https://");
if (! active)
return prefix + s;
return Color::code (Color::blue, true) + prefix + s + Color::code ();
}
bool screen)
{ return colorize_raw (s, Color::blue, screen); }


class OColor
Expand Down Expand Up @@ -2978,21 +2979,24 @@ template <typename T>
{ operator= (other); }
template <typename U, typename V>
Set<T>& operator= (const map<U,V> &other)
{ universal = false;
{ P::clear ();
universal = false;
for (const auto& it : other)
P::insert (it. first);
return *this;
}
template <typename U, typename V>
Set<T>& operator= (const unordered_map<U,V> &other)
{ universal = false;
{ P::clear ();
universal = false;
for (const auto& it : other)
P::insert (it. first);
return *this;
}
template <typename U>
Set<T>& operator= (const vector<U> &other)
{ universal = false;
{ P::clear ();
universal = false;
for (const U& u : other)
P::insert (u);
return *this;
Expand Down Expand Up @@ -4459,7 +4463,10 @@ struct Application : Singleton<Application>, Root
{
const string description;
string version {"0.0.0"};
string documentationUrl;
// Without "https://"
string documentationUrl;
string updatesUrl;
//
string updatesDoc;
const bool needsArg;
const bool gnu;
Expand Down Expand Up @@ -4617,10 +4624,10 @@ struct Application : Singleton<Application>, Root
{}
virtual void initVar ()
{}
string getInstruction (bool coutP) const;
string getDocumentation () const;
string getUpdates () const;
virtual string getHelp () const;
string getInstruction (bool screen) const;
string getDocumentation (bool screen) const;
string getUpdates (bool screen) const;
virtual string getHelp (bool screen) const;
// Requires: must be printed to cout
string makeKey (const string &param,
const string &value) const
Expand Down Expand Up @@ -4678,7 +4685,7 @@ struct ShellApplication : Application
void initVar () override;
// stderr << "Running: " << getCommandLine ()
// threads_max correction
string getHelp () const override;
string getHelp (bool screen) const override;
private:
void body () const final;
virtual void shellBody () const = 0;
Expand Down
3 changes: 2 additions & 1 deletion stxtyper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Dependencies: NCBI BLAST, gunzip (optional)
*
* Release changes:
* 1.0.24 08/05/2024 PD-5076 "na" -> "NA"
* 1.0.23 07/29/2024 PD-5064 AMBIGUOUS operon type
* 1.0.22 07/25/2024 First codon L|I|V -> M
* 1.0.21 07/15/2024 PD-5038 --nucleotide_output
Expand Down Expand Up @@ -112,7 +113,7 @@ constexpr size_t intergenic_max {36}; // Max. intergenic region in the referenc
constexpr size_t slack = 30;

const string stxS ("stx");
const string na ("na");
const string na ("NA");



Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.23
1.0.24

0 comments on commit 62b3d0c

Please sign in to comment.