txtout command line action to export text file
This commit is contained in:
parent
1d8c2e11bd
commit
228e7d4676
|
@ -84,6 +84,9 @@ the following parameters may be used:
|
||||||
- `-cmdout path`: output command stream dump to `path`.
|
- `-cmdout path`: output command stream dump to `path`.
|
||||||
- you must provide a file, otherwise Furnace will quit.
|
- you must provide a file, otherwise Furnace will quit.
|
||||||
|
|
||||||
|
- `-txtout path`: output text file export to `path`.
|
||||||
|
- you must provide a file, otherwise Furnace will quit.
|
||||||
|
|
||||||
## COMMAND LINE INTERFACE
|
## COMMAND LINE INTERFACE
|
||||||
|
|
||||||
Furnace provides a command-line interface (CLI) player which may be activated through the `-console` option.
|
Furnace provides a command-line interface (CLI) player which may be activated through the `-console` option.
|
||||||
|
|
38
src/main.cpp
38
src/main.cpp
|
@ -86,6 +86,7 @@ FurnaceCLI cli;
|
||||||
String outName;
|
String outName;
|
||||||
String vgmOutName;
|
String vgmOutName;
|
||||||
String cmdOutName;
|
String cmdOutName;
|
||||||
|
String txtOutName;
|
||||||
int benchMode=0;
|
int benchMode=0;
|
||||||
int subsong=-1;
|
int subsong=-1;
|
||||||
DivAudioExportOptions exportOptions;
|
DivAudioExportOptions exportOptions;
|
||||||
|
@ -437,6 +438,12 @@ TAParamResult pCmdOut(String val) {
|
||||||
return TA_PARAM_SUCCESS;
|
return TA_PARAM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAParamResult pTxtOut(String val) {
|
||||||
|
txtOutName=val;
|
||||||
|
e.setAudio(DIV_AUDIO_DUMMY);
|
||||||
|
return TA_PARAM_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
bool needsValue(String param) {
|
bool needsValue(String param) {
|
||||||
for (size_t i=0; i<params.size(); i++) {
|
for (size_t i=0; i<params.size(); i++) {
|
||||||
if (params[i].name==param) {
|
if (params[i].name==param) {
|
||||||
|
@ -454,6 +461,7 @@ void initParams() {
|
||||||
params.push_back(TAParam("O","vgmout",true,pVGMOut,"<filename>","output .vgm data"));
|
params.push_back(TAParam("O","vgmout",true,pVGMOut,"<filename>","output .vgm data"));
|
||||||
params.push_back(TAParam("D","direct",false,pDirect,"","set VGM export direct stream mode"));
|
params.push_back(TAParam("D","direct",false,pDirect,"","set VGM export direct stream mode"));
|
||||||
params.push_back(TAParam("C","cmdout",true,pCmdOut,"<filename>","output command stream"));
|
params.push_back(TAParam("C","cmdout",true,pCmdOut,"<filename>","output command stream"));
|
||||||
|
params.push_back(TAParam("t","txtout",true,pTxtOut,"<filename>","export as text file"));
|
||||||
params.push_back(TAParam("L","loglevel",true,pLogLevel,"debug|info|warning|error","set the log level (info by default)"));
|
params.push_back(TAParam("L","loglevel",true,pLogLevel,"debug|info|warning|error","set the log level (info by default)"));
|
||||||
params.push_back(TAParam("v","view",true,pView,"pattern|commands|nothing","set visualization (nothing by default)"));
|
params.push_back(TAParam("v","view",true,pView,"pattern|commands|nothing","set visualization (nothing by default)"));
|
||||||
params.push_back(TAParam("i","info",false,pInfo,"","get info about a song"));
|
params.push_back(TAParam("i","info",false,pInfo,"","get info about a song"));
|
||||||
|
@ -549,6 +557,7 @@ int main(int argc, char** argv) {
|
||||||
outName="";
|
outName="";
|
||||||
vgmOutName="";
|
vgmOutName="";
|
||||||
cmdOutName="";
|
cmdOutName="";
|
||||||
|
txtOutName="";
|
||||||
|
|
||||||
// load config for locale
|
// load config for locale
|
||||||
e.prePreInit();
|
e.prePreInit();
|
||||||
|
@ -716,14 +725,14 @@ int main(int argc, char** argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileName.empty() && (benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
|
if (fileName.empty() && (benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="" || txtOutName!="")) {
|
||||||
logE("provide a file!");
|
logE("provide a file!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GUI
|
#ifdef HAVE_GUI
|
||||||
if (e.preInit(consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
|
if (e.preInit(consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="" || txtOutName!="")) {
|
||||||
if (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="") {
|
if (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="" || txtOutName!="") {
|
||||||
logW("engine wants safe mode, but Furnace GUI is not going to start.");
|
logW("engine wants safe mode, but Furnace GUI is not going to start.");
|
||||||
} else {
|
} else {
|
||||||
safeMode=true;
|
safeMode=true;
|
||||||
|
@ -735,7 +744,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (safeMode && (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
|
if (safeMode && (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="" || txtOutName!="")) {
|
||||||
logE("you can't use safe mode and console/export mode together.");
|
logE("you can't use safe mode and console/export mode together.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -752,7 +761,7 @@ int main(int argc, char** argv) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",TUT_INTRO_PLAYED)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
|
if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",TUT_INTRO_PLAYED)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="" || txtOutName!="")) {
|
||||||
logI("loading module...");
|
logI("loading module...");
|
||||||
FILE* f=ps_fopen(fileName.c_str(),"rb");
|
FILE* f=ps_fopen(fileName.c_str(),"rb");
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
|
@ -844,7 +853,7 @@ int main(int argc, char** argv) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outName!="" || vgmOutName!="" || cmdOutName!="") {
|
if (outName!="" || vgmOutName!="" || cmdOutName!="" || txtOutName!="") {
|
||||||
if (cmdOutName!="") {
|
if (cmdOutName!="") {
|
||||||
SafeWriter* w=e.saveCommand();
|
SafeWriter* w=e.saveCommand();
|
||||||
if (w!=NULL) {
|
if (w!=NULL) {
|
||||||
|
@ -882,6 +891,23 @@ int main(int argc, char** argv) {
|
||||||
e.saveAudio(outName.c_str(),exportOptions);
|
e.saveAudio(outName.c_str(),exportOptions);
|
||||||
e.waitAudioFile();
|
e.waitAudioFile();
|
||||||
}
|
}
|
||||||
|
if (txtOutName!="") {
|
||||||
|
e.setConsoleMode(true);
|
||||||
|
SafeWriter* w=e.saveText(false);
|
||||||
|
if (w!=NULL) {
|
||||||
|
FILE* f=fopen(txtOutName.c_str(),"wb");
|
||||||
|
if (f!=NULL) {
|
||||||
|
fwrite(w->getFinalBuf(),1,w->size(),f);
|
||||||
|
fclose(f);
|
||||||
|
} else {
|
||||||
|
reportError(fmt::sprintf(_("could not open file! (%s)"),e.getLastError()));
|
||||||
|
}
|
||||||
|
w->finish();
|
||||||
|
delete w;
|
||||||
|
} else {
|
||||||
|
reportError(_("could not write txt!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
finishLogFile();
|
finishLogFile();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue