summaryrefslogtreecommitdiff
path: root/session_utils
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-09-27 18:50:24 +0200
committerRobin Gareus <robin@gareus.org>2017-09-27 18:50:24 +0200
commite96fd26f3f71801868c78b71e4467356ff81a73f (patch)
tree1106d3967798d82ea5d7c91a519f1bce2c76bd34 /session_utils
parent476952f2b60f595c2d7378af1b3db4eb41e2c13c (diff)
Minor refinement of new session util
Diffstat (limited to 'session_utils')
-rw-r--r--session_utils/new_empty_session.cc37
1 files changed, 29 insertions, 8 deletions
diff --git a/session_utils/new_empty_session.cc b/session_utils/new_empty_session.cc
index 21eb6879a2..6dc0151d0b 100644
--- a/session_utils/new_empty_session.cc
+++ b/session_utils/new_empty_session.cc
@@ -2,6 +2,8 @@
#include <cstdlib>
#include <getopt.h>
+#include <glibmm.h>
+
#include "common.h"
using namespace std;
@@ -13,19 +15,24 @@ static void usage (int status)
{
// help2man compatible format (standard GNU help-text)
printf (UTILNAME " - create a new empty session from the commandline.\n\n");
- printf ("Usage: " UTILNAME " [ OPTIONS ] <session-dir> <session/snapshot-name>\n\n");
+ printf ("Usage: " UTILNAME " [ OPTIONS ] <session-dir> [session-name]\n\n");
printf ("Options:\n\
-h, --help display this help and exit\n\
-s, --samplerate <rate> samplerate to use (default 48000)\n\
-V, --version print version information and exit\n\
\n");
+
printf ("\n\
This tool creates a new empty Ardour session.\n\
\n\
-Note: the tool expects a session-name without .ardour file-name extension.\n\
-\n\
+If the session-name is unspecified, the sesion-dir-name is used.\n\
+If specified, the tool expects a session-name without .ardour\n\
+file-name extension.\n\
+\n");
+
+ printf ("\n\
Examples:\n\
-"UTILNAME " -s 44100 /tmp/TestSession TestSession\n\
+" UTILNAME " -s 44100 /tmp/TestSession TestSession\n\
\n");
printf ("Report bugs to <http://tracker.ardour.org/>\n"
@@ -76,21 +83,35 @@ int main (int argc, char* argv[])
}
}
- // XXX perhaps allow to infer the session-name from the dir-name
- if (optind + 2 > argc) {
+ std::string snapshot_name;
+
+ if (optind + 2 == argc) {
+ snapshot_name = argv[optind+1];
+ } else if (optind + 1 == argc) {
+ snapshot_name = Glib::path_get_basename (argv[optind]);
+ } else {
usage (EXIT_FAILURE);
}
+ if (snapshot_name.empty ()) {
+ fprintf(stderr, "Error: Invalid empty session/snapshot name.\n");
+ ::exit (EXIT_FAILURE);
+ }
+
/* all systems go */
SessionUtils::init();
Session* s = 0;
- s = SessionUtils::create_session (argv[optind], argv[optind+1], sample_rate);
+ s = SessionUtils::create_session (argv[optind], snapshot_name, sample_rate);
/* save is implicit when creating a new session */
- SessionUtils::unload_session(s);
+ if (s) {
+ std::cout << "Created session in '" << s->path () <<"'" << std::endl;
+ }
+
+ SessionUtils::unload_session (s);
SessionUtils::cleanup();
return 0;