Skip to content

Commit

Permalink
provide access to version string from command line class
Browse files Browse the repository at this point in the history
renamed version() to isVersionOption() to mirror isHelpOption()
added new public version() to provide access to the version string
  • Loading branch information
thunder422 committed Dec 9, 2012
1 parent e27358a commit 5431b8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 11 additions & 5 deletions commandline.cpp
Expand Up @@ -47,7 +47,7 @@ CommandLine::CommandLine(const QStringList &args)
// NOTE: leave m_returnCode set to -1 to start GUI,

// parse command line arguments
if (version(args))
if (isVersionOption(args))
{
m_returnCode = 0;
return;
Expand Down Expand Up @@ -116,15 +116,14 @@ void CommandLine::coutClose(void)
}


// function to print version number
bool CommandLine::version(const QStringList &args)
// function to check if version option was specified and to process it
bool CommandLine::isVersionOption(const QStringList &args)
{
if (args.count() != 2 || args.at(1) != "-v")
{
return false; // not our option or extra/invalid options
}
cout() << tr("%1 version %2").arg(m_programName)
.arg(ibcp_RELEASE_STRING + 7) << endl;
cout() << tr("%1 version %2").arg(m_programName).arg(version()) << endl;
return true;
}

Expand All @@ -143,4 +142,11 @@ int CommandLine::copyrightYear(void) const
}


// function to return the version number string
QString CommandLine::version(void) const
{
return QString(ibcp_RELEASE_STRING + 7);
}


// end: commandline.cpp
3 changes: 2 additions & 1 deletion commandline.h
Expand Up @@ -33,9 +33,9 @@ class CommandLine
{
Q_DECLARE_TR_FUNCTIONS(CommandLine)

bool version(const QStringList &args);
QTextStream &cout(FILE *stream = stdout);
void coutClose(void);
bool isVersionOption(const QStringList &args);
bool isHelpOption(const QStringList &args) const;

static const char *s_gplStatement[];
Expand All @@ -59,6 +59,7 @@ class CommandLine
{
return m_programName;
}
QString version(void) const;
int copyrightYear(void) const;
static const char **gplStatement(void)
{
Expand Down

0 comments on commit 5431b8f

Please sign in to comment.