From e96fd26f3f71801868c78b71e4467356ff81a73f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 27 Sep 2017 18:50:24 +0200 Subject: Minor refinement of new session util --- session_utils/new_empty_session.cc | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'session_utils') 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 #include +#include + #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 ] \n\n"); + printf ("Usage: " UTILNAME " [ OPTIONS ] [session-name]\n\n"); printf ("Options:\n\ -h, --help display this help and exit\n\ -s, --samplerate 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 \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; -- cgit v1.2.3