Fix cmd-line help, add config option, use local lmmsrc file in dev (#2570)

* Fix command-line help, add --config option and use local lmmsrc file in dev mode

* Fix a typo in help screen for option --geometry (second dash missing)

* Replace tabs with spaces in help screen
Update man page

* Lineup items in help screen

* Accept both -geometry and --geometry as valid options
This commit is contained in:
midi-pascal
2016-04-23 17:27:34 -04:00
committed by Umcaruje
parent 0381e412c4
commit 2a7bdf3fe8
4 changed files with 174 additions and 59 deletions

View File

@@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH LMMS 1 "June 23, 2015"
.TH LMMS 1 "February 17, 2016"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@@ -19,13 +19,58 @@
lmms \- software for easy music production
.SH SYNOPSIS
.B lmms
.RB "[ \--\fBallowroot\fP ]"
.br
.B lmms
.RB "[ \--\fBbitrate\fP \fIbitrate\fP ]"
.br
.B lmms
.RB "[ \--\fBconfig\fP \fIconfigfile\fP ]"
.br
.B lmms
.RB "[ \--\fBdump\fP \fIin\fP ]"
.br
.B lmms
.RB "[ \--\fBfloat\fP ]"
.br
.B lmms
.RB "[ \--\fBformat\fP \fIformat\fP ]"
.br
.B lmms
.RB "[ \--\fBgeometry\fP \fIgeometry\fP ]"
.br
.B lmms
.RB "[ \--\fBhelp\fP ]"
.br
.B lmms
.RB "[ \--\interpolation\fP \fImethod\fP ]"
.br
.B lmms
.RB "[ \--\fBimport\fP \fIin\fP [ \-e ] ]"
.br
.B lmms
.RB "[ \--\fBloop\fP ]"
.br
.B lmms
.RB "[ \--\fBoutput\fP \fIpath\fP ]"
.br
.B lmms
.RB "[ \--\fBoversampling\fP \fIvalue\fP ]"
.br
.B lmms
.RB "[ \--\fBprofile\fP \fIout\fP ]"
.br
.B lmms
.RB "[ \--\fBrender\fP \fIfile\fP ] [options]"
.br
.B lmms
.RB "[ \--\fBsamplerate\fP \fIsamplerate\fP ]"
.br
.B lmms
.RB "[ \--\fBupgrade\fP \fIin\fP \fIout\fP ]"
.br
.B lmms
.RB "[ \--\fBdump\fP \fIin\fP ]"
.RB "[ \--\fBversion\fP ]"
.br
.B lmms
.RI "[ file ]"
@@ -40,38 +85,54 @@ LMMS is a free cross-platform alternative to commercial programs like FL Studio
LMMS features components such as a Song Editor, a Beat+Bassline Editor, a Piano Roll, an FX Mixer as well as many powerful instruments and effects.
.SH OPTIONS
.IP "\fB\-r, --render\fP \fIproject-file\fP
Render given file to either a wav\- or ogg\-file. See \fB\-f\fP for details
.IP "\fB\-r, --rendertracks\fP \fIproject-file\fP
Render each track into a separate wav\- or ogg\-file. See \fB\-f\fP for details
.IP "\fB\-a, --float\fP
32bit float bit depth
.IP "\fB\-b, --bitrate\fP \fIbitrate\fP
Specify output bitrate in KBit/s (for OGG encoding only), default is 160
.IP "\fB\-c, --config\fP \fIconfigfile\fP
Get the configuration from \fIconfigfile\fP instead of ~/.lmmsrc.xml (default)
.IP "\fB\-d, --dump\fP \fIin\fP
Dump XML of compressed file \fIin\fP (i.e. MMPZ-file)
.IP "\fB\-f, --format\fP \fIformat\fP
Specify format of render-output where \fIformat\fP is either 'wav' or 'ogg'
.IP "\fB\ --geometry\fP \fIgeometry\fP
Specify the prefered size and position of the main window
.br
\fIgeometry\fP syntax is <\fIxsize\fPx\fIysize\fP+\fIxoffset\fP+\fIyoffset\fP>.
.br
Default: full screen
.IP "\fB\-h, --help\fP
Show usage information and exit.
.IP "\fB\-i, --interpolation\fP \fImethod\fP
Specify interpolation method - possible values are \fIlinear\fP, \fIsincfastest\fP (default), \fIsincmedium\fP, \fIsincbest\fP
.IP "\fB\ --import\fP \fIin\fP \fB\-e\fP
Import MIDI file \fIin\fP
.br
If -e is specified lmms exits after importing the file.
.IP "\fB\-l, --loop
Render the given file as a loop, i.e. stop rendering at exactly the end of the song. Additional silence or reverb tails at the end of the song are not rendered.
.IP "\fB\-o, --output\fP \fIpath\fP
Render into \fIpath\fP
.br
For --render, this is interpreted as a file path.
.br
For --render-tracks, this is interpreted as a path to an existing directory.
.IP "\fB\-f, --format\fP \fIformat\fP
Specify format of render-output where \fIformat\fP is either 'wav' or 'ogg'
IP "\fB\-p, --profile\fP \fIout\fP
Dump profiling information to file \fIout\fP
.IP "\fB\-r, --render\fP \fIproject-file\fP
Render given file to either a wav\- or ogg\-file. See \fB\-f\fP for details
.IP "\fB\-r, --rendertracks\fP \fIproject-file\fP
Render each track into a separate wav\- or ogg\-file. See \fB\-f\fP for details
.IP "\fB\-s, --samplerate\fP \fIsamplerate\fP
Specify output samplerate in Hz - range is 44100 (default) to 192000
.IP "\fB\-b, --bitrate\fP \fIbitrate\fP
Specify output bitrate in KBit/s (for OGG encoding only), default is 160
.IP "\fB\-i, --interpolation\fP \fImethod\fP
Specify interpolation method - possible values are \fIlinear\fP, \fIsincfastest\fP (default), \fIsincmedium\fP, \fIsincbest\fP
.IP "\fB\-x, --oversampling\fP \fIvalue\fP
Specify oversampling, possible values: 1, 2 (default), 4, 8
.IP "\fB\-l, --loop
Render the given file as a loop, i.e. stop rendering at exactly the end of the song. Additional silence or reverb tails at the end of the song are not rendered.
.IP "\fB\-u, --upgrade\fP \fIin\fP \fIout\fP
Upgrade file \fIin\fP and save as \fIout\fP
.IP "\fB\-d, --dump\fP \fIin\fP
Dump XML of compressed file \fIin\fP (i.e. MMPZ-file)
.IP "\fB\-v, --version
Show version information and exit.
.IP "\fB\-x, --oversampling\fP \fIvalue\fP
Specify oversampling, possible values: 1, 2 (default), 4, 8
.IP "\fB\ --allowroot
Bypass root user startup check (use with caution).
.IP "\fB\-h, --help
Show usage information and exit.
.SH SEE ALSO
.BR https://lmms.io/
.BR https://lmms.io/documentation/

View File

@@ -230,7 +230,7 @@ public:
const QString & value );
void deleteValue( const QString & cls, const QString & attribute);
void loadConfigFile();
void loadConfigFile( const QString & configFile = "" );
void saveConfigFile();
@@ -260,7 +260,7 @@ private:
void upgrade_1_1_90();
void upgrade();
const QString m_lmmsRcFile;
QString m_lmmsRcFile;
QString m_workingDir;
QString m_dataDir;
QString m_artworkDir;

View File

@@ -63,14 +63,16 @@ ConfigManager::ConfigManager() :
if (! qgetenv("LMMS_DATA_DIR").isEmpty())
QDir::addSearchPath("data", QString::fromLocal8Bit(qgetenv("LMMS_DATA_DIR")));
// If we're in development (lmms is not installed) let's get the source
// directory by reading the CMake Cache
// If we're in development (lmms is not installed) let's get the source and
// binary directories by reading the CMake Cache
QFile cmakeCache(qApp->applicationDirPath() + "/CMakeCache.txt");
if (cmakeCache.exists()) {
cmakeCache.open(QFile::ReadOnly);
QTextStream stream(&cmakeCache);
// Find the line containing something like lmms_SOURCE_DIR:static=<dir>
// Find the lines containing something like lmms_SOURCE_DIR:static=<dir>
// and lmms_BINARY_DIR:static=<dir>
int done = 0;
while(! stream.atEnd())
{
QString line = stream.readLine();
@@ -78,6 +80,15 @@ ConfigManager::ConfigManager() :
if (line.startsWith("lmms_SOURCE_DIR:")) {
QString srcDir = line.section('=', -1).trimmed();
QDir::addSearchPath("data", srcDir + "/data/");
done++;
}
if (line.startsWith("lmms_BINARY_DIR:")) {
m_lmmsRcFile = line.section('=', -1).trimmed() + QDir::separator() +
".lmmsrc.xml";
done++;
}
if (done == 2)
{
break;
}
}
@@ -331,9 +342,15 @@ void ConfigManager::deleteValue( const QString & cls, const QString & attribute)
}
void ConfigManager::loadConfigFile()
void ConfigManager::loadConfigFile( const QString & configFile )
{
// read the XML file and create DOM tree
// Allow configuration file override through --config commandline option
if ( !configFile.isEmpty() )
{
m_lmmsRcFile = configFile;
}
QFile cfg_file( m_lmmsRcFile );
QDomDocument dom_tree;

View File

@@ -116,39 +116,58 @@ void printHelp()
{
printf( "LMMS %s\n"
"Copyright (c) %s\n\n"
"Usage: lmms [ -r <project file> ] [ options ]\n"
" [ -u <in> <out> ]\n"
"Usage: lmms [ -a ]\n"
" [ -b <bitrate> ]\n"
" [ -c <configfile> ]\n"
" [ -d <in> ]\n"
" [ -f <format> ]\n"
" [ --geometry <geometry> ]\n"
" [ -h ]\n"
" [ -i <method> ]\n"
" [ --import <in> [-e]]\n"
" [ -l ]\n"
" [ -o <path> ]\n"
" [ -p <out> ]\n"
" [ -r <project file> ] [ options ]\n"
" [ -s <samplerate> ]\n"
" [ -u <in> <out> ]\n"
" [ -v ]\n"
" [ -x <value> ]\n"
" [ <file to load> ]\n\n"
"-r, --render <project file> Render given project file\n"
" --rendertracks <project> Render each track to a different file\n"
"-o, --output <path> Render into <path>\n"
" For --render, provide a file path\n"
" For --rendertracks, provide a directory path\n"
"-f, --format <format> Specify format of render-output where\n"
" Format is either 'wav' or 'ogg'.\n"
"-s, --samplerate <samplerate> Specify output samplerate in Hz\n"
" Range: 44100 (default) to 192000\n"
"-b, --bitrate <bitrate> Specify output bitrate in KBit/s\n"
" Default: 160.\n"
"-i, --interpolation <method> Specify interpolation method\n"
" Possible values:\n"
" - linear\n"
" - sincfastest (default)\n"
" - sincmedium\n"
" - sincbest\n"
"-x, --oversampling <value> Specify oversampling\n"
" Possible values: 1, 2, 4, 8\n"
" Default: 2\n"
"-a, --float 32bit float bit depth\n"
"-l, --loop Render as a loop\n"
"-u, --upgrade <in> [out] Upgrade file <in> and save as <out>\n"
"-a, --float 32bit float bit depth\n"
"-b, --bitrate <bitrate> Specify output bitrate in KBit/s\n"
" Default: 160.\n"
"-c, --config <configfile> Get the configuration from <configfile>\n"
"-d, --dump <in> Dump XML of compressed file <in>\n"
"-f, --format <format> Specify format of render-output where\n"
" Format is either 'wav' or 'ogg'.\n"
" --geometry <geometry> Specify the size and position of the main window\n"
" geometry is <xsizexysize+xoffset+yoffsety>.\n"
"-h, --help Show this usage information and exit.\n"
"-i, --interpolation <method> Specify interpolation method\n"
" Possible values:\n"
" - linear\n"
" - sincfastest (default)\n"
" - sincmedium\n"
" - sincbest\n"
" --import <in> [-e] Import MIDI file <in>.\n"
" If -e is specified lmms exits after importing the file.\n"
"-l, --loop Render as a loop\n"
"-o, --output <path> Render into <path>\n"
" For --render, provide a file path\n"
" For --rendertracks, provide a directory path\n"
"-p, --profile <out> Dump profiling information to file <out>\n"
"-r, --render <project file> Render given project file\n"
" --rendertracks <project> Render each track to a different file\n"
"-s, --samplerate <samplerate> Specify output samplerate in Hz\n"
" Range: 44100 (default) to 192000\n"
"-u, --upgrade <in> [out] Upgrade file <in> and save as <out>\n"
" Standard out is used if no output file is specifed\n"
"-d, --dump <in> Dump XML of compressed file <in>\n"
"-v, --version Show version information and exit.\n"
" --allowroot Bypass root user startup check (use with caution).\n"
"-h, --help Show this usage information and exit.\n\n",
"-v, --version Show version information and exit.\n"
" --allowroot Bypass root user startup check (use with caution).\n"
"-x, --oversampling <value> Specify oversampling\n"
" Possible values: 1, 2, 4, 8\n"
" Default: 2\n\n",
LMMS_VERSION, LMMS_PROJECT_COPYRIGHT );
}
@@ -172,7 +191,7 @@ int main( int argc, char * * argv )
bool allowRoot = false;
bool renderLoop = false;
bool renderTracks = false;
QString fileToLoad, fileToImport, renderOut, profilerOutputFile;
QString fileToLoad, fileToImport, renderOut, profilerOutputFile, configFile;
// first of two command-line parsing stages
for( int i = 1; i < argc; ++i )
@@ -194,8 +213,13 @@ int main( int argc, char * * argv )
{
allowRoot = true;
}
else if( arg == "-geometry" )
else if( arg == "--geometry" || arg == "-geometry")
{
if( arg == "--geometry" )
{
// Delete the first "-" so Qt recognize the option
strcpy(argv[i], "-geometry");
}
// option -geometry is filtered by Qt later,
// so we need to check its presence now to
// determine, if the application should run in
@@ -514,7 +538,20 @@ int main( int argc, char * * argv )
}
profilerOutputFile = QString::fromLocal8Bit( argv[1] );
profilerOutputFile = QString::fromLocal8Bit( argv[i] );
}
else if( arg == "--config" || arg == "-c" )
{
++i;
if( i == argc )
{
printf( "\nNo configuration file specified.\n\n"
"Try \"%s --help\" for more information.\n\n", argv[0] );
return EXIT_FAILURE;
}
configFile = QString::fromLocal8Bit( argv[i] );
}
else
{
@@ -529,7 +566,7 @@ int main( int argc, char * * argv )
}
ConfigManager::inst()->loadConfigFile();
ConfigManager::inst()->loadConfigFile(configFile);
// set language
QString pos = ConfigManager::inst()->value( "app", "language" );