Skip to content

Commit

Permalink
Move ezOptionParser to third_party directory. Update to latest version.
Browse files Browse the repository at this point in the history
  • Loading branch information
nealkruis committed Sep 12, 2014
1 parent e923866 commit 52b38b6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
17 changes: 8 additions & 9 deletions src/EnergyPlus/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include <ObjexxFCL/string.functions.hh>
#include <ObjexxFCL/Time_Date.hh>

// CLI Headers
#include <../../CLI/ezOptionParser.hpp> // Added by Monika Sharma for CLI
#include <stdio.h> // Added by Monika Sharma for CLI

// EnergyPlus Headers
#include <main.hh>
#include <DataEnvironment.hh>
Expand All @@ -29,9 +33,6 @@
#include <ScheduleManager.hh>
#include <SimulationManager.hh>
#include <UtilityRoutines.hh>
#include <stdio.h> // Added by Monika Sharma for CLI
#include "ezOptionParser.hpp" // Added by Monika Sharma for CLI
//#include <Globals.hh>

using namespace ez;
using namespace std;
Expand Down Expand Up @@ -232,8 +233,8 @@ main(int argc, const char * argv[])
ezOptionParser opt;

opt.overview = "\n*******************************************\nCopyright (C) 2012-2014 Big Ladder Software\nWeb: www.bigladdersoftware.com\n";
opt.overview1 = VerString;
opt.overview2 = "\n*******************************************\n";
opt.overview += VerString;
opt.overview += "\n*******************************************\n";
opt.syntax = "./EnergyPlus -df InputFile.idf -i Energy+.idd -w WeatherFile.epw -o OutFile.csv";

opt.add(
Expand Down Expand Up @@ -313,7 +314,6 @@ main(int argc, const char * argv[])
if(argv[1]==0) cout<<"No arguments provided"<<endl;

std::string usage;
std::string version;

if (opt.isSet("-h")) {
opt.getUsage(usage);
Expand All @@ -322,8 +322,7 @@ main(int argc, const char * argv[])
}

if (opt.isSet("-v")) {
opt.getVersion(version);
cout << version;
cout << VerString;
return 1;
}

Expand All @@ -334,7 +333,7 @@ main(int argc, const char * argv[])

opt.getUsage(usage);
cout << usage;
return 1;
return -1;
}

/* if(!opt.gotRequired(badOptions)) {
Expand Down
7 changes: 7 additions & 0 deletions third_party/CLI/MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (C) 2011,2012 Remik Ziemlinski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13 changes: 0 additions & 13 deletions src/EnergyPlus/ezOptionParser.hpp → third_party/CLI/ezOptionParser.hpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,6 @@ class ezOptionParser {
inline bool exportFile(const char * filename, bool all=false);
inline OptionGroup * get(const char * name);
inline void getUsage(std::string & usage, int width=80, Layout layout=ALIGN);
inline void getVersion(std::string & version, int width=80, Layout layout=ALIGN);
inline void getUsageDescriptions(std::string & usage, int width=80, Layout layout=STAGGER);
inline bool gotExpected(std::vector<std::string> & badOptions);
inline bool gotRequired(std::vector<std::string> & badOptions);
Expand All @@ -1346,8 +1345,6 @@ class ezOptionParser {
// General description in human language on what the user's tool does.
// It's the first section to get printed in the full usage message.
std::string overview;
std::string overview1;
std::string overview2;
// A synopsis of command and options usage to show expected order of input arguments.
// It's the second section to get printed in the full usage message.
std::string syntax;
Expand Down Expand Up @@ -1781,8 +1778,6 @@ OptionGroup * ezOptionParser::get(const char * name) {
void ezOptionParser::getUsage(std::string & usage, int width, Layout layout) {

usage.append(overview);
usage.append(overview1);
usage.append(overview2);
usage.append("\n\n");
usage.append("USAGE: ");
usage.append(syntax);
Expand All @@ -1799,14 +1794,6 @@ void ezOptionParser::getUsage(std::string & usage, int width, Layout layout) {
}
};
/* ################################################################### */
void ezOptionParser::getVersion(std::string & version, int width, Layout layout) {

version.append(overview);
version.append(overview1);
version.append(overview2);
version.append("\n\n");
};
/* ################################################################### */
// Creates 2 column formatted help descriptions for each option flag.
void ezOptionParser::getUsageDescriptions(std::string & usage, int width, Layout layout) {
// Sort each flag list amongst each group.
Expand Down

10 comments on commit 52b38b6

@nealkruis
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbenne When you get a chance, let me know if this structure works for you. Currently, the parser library is a single header in third_party/CLI with a relative reference from the EnergyPlus source. Alternatively, we can compile as a separate shared library like the other third party libraries if you think that'd be cleaner.

@kbenne
Copy link
Contributor

@kbenne kbenne commented on 52b38b6 Sep 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nealkruis you read my mind. I was about ready to send you a note on the previous commit that CLI should go in third party. Its header only so there is no library to compile. What you have is fine. Those direct calls to cout got my attention too. I'm not sure, you might be the first person to be calling cout directly.

@nealkruis
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monika0603 @kbenne Something about having a big relative reference in an #include statement doesn't feel as clean as the way the ObjexxFCL library is included. Is there a better way around this?

As far as the direct cout calls go, I imagine they will be replaced with DisplayString unless the team plans to transition away anyway. We have a few other stylistic changes and to make before we put out a pull request. We'll also be moving the command line parser functionality to a new source file.

@kbenne
Copy link
Contributor

@kbenne kbenne commented on 52b38b6 Sep 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah I should have caught that. Use angle brackets and add an include_directories line like this if you need.

https://github.com/NREL/EnergyPlusTeam/blob/develop/CMakeLists.txt#L71

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (nealkruis) - x86_64-Linux-Ubuntu-14.04-gcc-4.8: Build Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (nealkruis) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed)

Build Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (nealkruis) - x86_64-MacOS-10.9-clang: Tests Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (nealkruis) - i386-Windows-7-VisualStudio-12: Tests Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (nealkruis) - x86_64-MacOS-10.9-clang-Debug: Tests Failed

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1277852-CommandLineInterface (nealkruis) - Win64-Windows-7-VisualStudio-12: Tests Failed

Build Badge Test Badge

Please sign in to comment.