# HG changeset patch # User Sebastien Jodogne # Date 1352115062 -3600 # Node ID 662af781a22712610041bd8df5b37dfd8d3feedd # Parent 43471da12ab90b230177f9f3c29ad2fc890c426e sample config file from command line diff -r 43471da12ab9 -r 662af781a227 CMakeLists.txt --- a/CMakeLists.txt Fri Oct 26 16:47:11 2012 +0200 +++ b/CMakeLists.txt Mon Nov 05 12:31:02 2012 +0100 @@ -47,6 +47,7 @@ EmbedResources( PREPARE_DATABASE OrthancServer/PrepareDatabase.sql ORTHANC_EXPLORER OrthancExplorer + CONFIGURATION_SAMPLE Resources/Configuration.json ) else() add_definitions( @@ -55,6 +56,7 @@ ) EmbedResources( PREPARE_DATABASE OrthancServer/PrepareDatabase.sql + CONFIGURATION_SAMPLE Resources/Configuration.json ) endif() diff -r 43471da12ab9 -r 662af781a227 NEWS --- a/NEWS Fri Oct 26 16:47:11 2012 +0200 +++ b/NEWS Mon Nov 05 12:31:02 2012 +0100 @@ -1,7 +1,7 @@ Pending changes in the mainline =============================== -None +* Generate a sample configuration file from command line Version 0.2.3 (2012/10/26) diff -r 43471da12ab9 -r 662af781a227 OrthancServer/main.cpp --- a/OrthancServer/main.cpp Fri Oct 26 16:47:11 2012 +0200 +++ b/OrthancServer/main.cpp Mon Nov 05 12:31:02 2012 +0100 @@ -32,7 +32,7 @@ #include "OrthancRestApi.h" -#include +#include #include #include @@ -106,19 +106,21 @@ { std::cout << "Usage: " << path << " [OPTION]... [CONFIGURATION]" << std::endl - << "Start Orthanc, a lightweight, RESTful DICOM server for healthcare and medical research." << std::endl + << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research." << std::endl << std::endl - << "If no configuration file is given on the command line, a set of default parameters " << std::endl - << "is used. Please refer to the Orthanc homepage for the full instructions about how to use Orthanc " << std::endl + << "If no configuration file is given on the command line, a set of default " << std::endl + << "parameters is used. Please refer to the Orthanc homepage for the full " << std::endl + << "instructions about how to use Orthanc " << std::endl << "." << std::endl << std::endl << "Command-line options:" << std::endl - << " --verbose\t\tbe verbose in logs" << std::endl - << " --trace\t\thighest verbosity in logs (for debug)" << std::endl << " --help\t\tdisplay this help and exit" << std::endl - << " --version\t\toutput version information and exit" << std::endl << " --logdir=[dir]\tdirectory where to store the log files" << std::endl << "\t\t\t(if not used, the logs are dumped to stderr)" << std::endl + << " --config=[file]\tcreate a sample configuration file and exit" << std::endl + << " --trace\t\thighest verbosity in logs (for debug)" << std::endl + << " --verbose\t\tbe verbose in logs" << std::endl + << " --version\t\toutput version information and exit" << std::endl << std::endl << "Exit status:" << std::endl << " 0 if OK," << std::endl @@ -177,6 +179,18 @@ FLAGS_logtostderr = false; FLAGS_log_dir = std::string(argv[i]).substr(9); } + + if (boost::starts_with(argv[i], "--config=")) + { + std::string configurationSample; + GetFileResource(configurationSample, EmbeddedResources::CONFIGURATION_SAMPLE); + + std::string target = std::string(argv[i]).substr(9); + std::ofstream f(target.c_str()); + f << configurationSample; + f.close(); + return 0; + } } google::InitGoogleLogging("Orthanc");