added -q (quiet) command line parameter to a couple of tools, to allow usage in scripts.

develop
rofl0r 2010-11-11 02:09:43 +01:00
parent a5d21e612b
commit 0df38244e4
6 changed files with 87 additions and 17 deletions

@ -8,9 +8,20 @@ using namespace std;
#include <DFHack.h> #include <DFHack.h>
int main (void) int main (int argc, char** argv)
{ {
uint32_t x_max,y_max,z_max;
bool quiet = false;
for(int i = 1; i < argc; i++)
{
string test = argv[i];
if(test == "-q")
{
quiet = true;
}
}
uint32_t x_max,y_max,z_max;
uint32_t num_blocks = 0; uint32_t num_blocks = 0;
uint32_t bytes_read = 0; uint32_t bytes_read = 0;
vector<DFHack::t_spattervein> splatter; vector<DFHack::t_spattervein> splatter;
@ -72,8 +83,11 @@ int main (void)
} }
DF->Detach(); DF->Detach();
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl; if (!quiet)
cin.ignore(); {
cout << "Done. Press any key to continue" << endl;
cin.ignore();
}
#endif #endif
return 0; return 0;
} }

@ -8,8 +8,18 @@ using namespace std;
#include <DFHack.h> #include <DFHack.h>
#include <dfhack/modules/Gui.h> #include <dfhack/modules/Gui.h>
int main (void) int main (int argc, char** argv)
{ {
bool quiet = false;
for(int i = 1; i < argc; i++)
{
string test = argv[i];
if(test == "-q")
{
quiet = true;
}
}
DFHack::ContextManager DFMgr("Memory.xml"); DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF; DFHack::Context *DF;
try try
@ -21,7 +31,7 @@ int main (void)
{ {
cerr << e.what() << endl; cerr << e.what() << endl;
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cin.ignore(); if(!quiet) cin.ignore();
#endif #endif
return 1; return 1;
} }
@ -33,7 +43,7 @@ int main (void)
DF->Resume(); DF->Resume();
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cout << "Done. The current game frame will have to finish first. This can take some time on bugged maps." << endl; cout << "Done. The current game frame will have to finish first. This can take some time on bugged maps." << endl;
cin.ignore(); if (!quiet) cin.ignore();
#endif #endif
return 0; return 0;
} }

@ -9,9 +9,18 @@ using namespace std;
#include <DFHack.h> #include <DFHack.h>
#include <dfhack/DFTileTypes.h> #include <dfhack/DFTileTypes.h>
int main (void) int main (int argc, char** argv)
{ {
int32_t x,y,z; bool quiet = false;
for(int i = 1; i < argc; i++)
{
string test = argv[i];
if(test == "-q")
{
quiet = true;
}
}
int32_t x,y,z;
DFHack::designations40d designations; DFHack::designations40d designations;
DFHack::tiletypes40d tiles; DFHack::tiletypes40d tiles;
DFHack::t_temperatures temp1,temp2; DFHack::t_temperatures temp1,temp2;
@ -460,8 +469,11 @@ int main (void)
} }
DF->Detach(); DF->Detach();
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl; if(!quiet)
cin.ignore(); {
cout << "Done. Press any key to continue" << endl;
cin.ignore();
}
#endif #endif
return 0; return 0;
} }

@ -8,8 +8,18 @@ using namespace std;
#include <DFHack.h> #include <DFHack.h>
int main (void) int main (int argc, char** argv)
{ {
bool quiet = false;
for(int i = 1; i < argc; i++)
{
string test = argv[i];
if(test == "-q")
{
quiet = true;
}
}
DFHack::Position * Position = 0; DFHack::Position * Position = 0;
DFHack::ContextManager DFMgr("Memory.xml"); DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF; DFHack::Context * DF;
@ -50,8 +60,11 @@ int main (void)
} }
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
if(!quiet)
{
cout << "Done. Press any key to continue" << endl; cout << "Done. Press any key to continue" << endl;
cin.ignore(); cin.ignore();
}
#endif #endif
return 0; return 0;
} }

@ -44,7 +44,7 @@ int main (int argc, const char* argv[])
bool showhidden = false; bool showhidden = false;
bool showbaselayers = false; bool showbaselayers = false;
for(int i = 0; i < argc; i++) for(int i = 1; i < argc; i++)
{ {
string test = argv[i]; string test = argv[i];
if(test == "-a") if(test == "-a")

@ -43,9 +43,26 @@ void printWeather(DFHack::WeatherType current)
} }
using namespace DFHack; using namespace DFHack;
int main (int numargs, const char ** args) int main (int argc, char** argv)
{ {
DFHack::ContextManager DFMgr("Memory.xml"); string command = "";
bool quiet = false;
bool cmdarg = false;
for(int i = 1; i < argc; i++)
{
string test = argv[i];
if(test == "-q")
{
quiet = true;
}
else
{
command = test;
cmdarg = true;
}
}
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext(); DFHack::Context *DF = DFMgr.getSingleContext();
try try
@ -68,9 +85,8 @@ int main (int numargs, const char ** args)
{ {
WeatherType current = (WeatherType) W->ReadCurrentWeather(); WeatherType current = (WeatherType) W->ReadCurrentWeather();
DF->Resume(); DF->Resume();
string command = "";
printWeather(current); printWeather(current);
getline(cin, command); if (command == "") getline(cin, command); // only read from stdin if command hasn't been passed on the console
DF->Suspend(); DF->Suspend();
if(command == "c") if(command == "c")
{ {
@ -88,10 +104,15 @@ int main (int numargs, const char ** args)
{ {
end = true; end = true;
} }
command = "";
if(cmdarg) end = true; // exit the loop when a cmd line arg has been passed.
} }
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
if (!quiet)
{
std::cout << "Done. Press any key to continue" << std::endl; std::cout << "Done. Press any key to continue" << std::endl;
cin.ignore(); cin.ignore();
}
#endif #endif
DF->Detach(); DF->Detach();
return 0; return 0;