Mercurial > hg > orthanc
comparison OrthancServer/main.cpp @ 175:662af781a227
sample config file from command line
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 05 Nov 2012 12:31:02 +0100 |
parents | 00604c758004 |
children | 5739b4d10a4b |
comparison
equal
deleted
inserted
replaced
174:43471da12ab9 | 175:662af781a227 |
---|---|
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #include "OrthancRestApi.h" | 33 #include "OrthancRestApi.h" |
34 | 34 |
35 #include <stdio.h> | 35 #include <fstream> |
36 #include <glog/logging.h> | 36 #include <glog/logging.h> |
37 #include <boost/algorithm/string/predicate.hpp> | 37 #include <boost/algorithm/string/predicate.hpp> |
38 | 38 |
39 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h" | 39 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h" |
40 #include "../Core/HttpServer/FilesystemHttpHandler.h" | 40 #include "../Core/HttpServer/FilesystemHttpHandler.h" |
104 | 104 |
105 void PrintHelp(char* path) | 105 void PrintHelp(char* path) |
106 { | 106 { |
107 std::cout | 107 std::cout |
108 << "Usage: " << path << " [OPTION]... [CONFIGURATION]" << std::endl | 108 << "Usage: " << path << " [OPTION]... [CONFIGURATION]" << std::endl |
109 << "Start Orthanc, a lightweight, RESTful DICOM server for healthcare and medical research." << std::endl | 109 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research." << std::endl |
110 << std::endl | 110 << std::endl |
111 << "If no configuration file is given on the command line, a set of default parameters " << std::endl | 111 << "If no configuration file is given on the command line, a set of default " << std::endl |
112 << "is used. Please refer to the Orthanc homepage for the full instructions about how to use Orthanc " << std::endl | 112 << "parameters is used. Please refer to the Orthanc homepage for the full " << std::endl |
113 << "instructions about how to use Orthanc " << std::endl | |
113 << "<https://code.google.com/p/orthanc/wiki/OrthancCookbook>." << std::endl | 114 << "<https://code.google.com/p/orthanc/wiki/OrthancCookbook>." << std::endl |
114 << std::endl | 115 << std::endl |
115 << "Command-line options:" << std::endl | 116 << "Command-line options:" << std::endl |
116 << " --verbose\t\tbe verbose in logs" << std::endl | |
117 << " --trace\t\thighest verbosity in logs (for debug)" << std::endl | |
118 << " --help\t\tdisplay this help and exit" << std::endl | 117 << " --help\t\tdisplay this help and exit" << std::endl |
119 << " --version\t\toutput version information and exit" << std::endl | |
120 << " --logdir=[dir]\tdirectory where to store the log files" << std::endl | 118 << " --logdir=[dir]\tdirectory where to store the log files" << std::endl |
121 << "\t\t\t(if not used, the logs are dumped to stderr)" << std::endl | 119 << "\t\t\t(if not used, the logs are dumped to stderr)" << std::endl |
120 << " --config=[file]\tcreate a sample configuration file and exit" << std::endl | |
121 << " --trace\t\thighest verbosity in logs (for debug)" << std::endl | |
122 << " --verbose\t\tbe verbose in logs" << std::endl | |
123 << " --version\t\toutput version information and exit" << std::endl | |
122 << std::endl | 124 << std::endl |
123 << "Exit status:" << std::endl | 125 << "Exit status:" << std::endl |
124 << " 0 if OK," << std::endl | 126 << " 0 if OK," << std::endl |
125 << " -1 if error (have a look at the logs)." << std::endl | 127 << " -1 if error (have a look at the logs)." << std::endl |
126 << std::endl; | 128 << std::endl; |
174 | 176 |
175 if (boost::starts_with(argv[i], "--logdir=")) | 177 if (boost::starts_with(argv[i], "--logdir=")) |
176 { | 178 { |
177 FLAGS_logtostderr = false; | 179 FLAGS_logtostderr = false; |
178 FLAGS_log_dir = std::string(argv[i]).substr(9); | 180 FLAGS_log_dir = std::string(argv[i]).substr(9); |
181 } | |
182 | |
183 if (boost::starts_with(argv[i], "--config=")) | |
184 { | |
185 std::string configurationSample; | |
186 GetFileResource(configurationSample, EmbeddedResources::CONFIGURATION_SAMPLE); | |
187 | |
188 std::string target = std::string(argv[i]).substr(9); | |
189 std::ofstream f(target.c_str()); | |
190 f << configurationSample; | |
191 f.close(); | |
192 return 0; | |
179 } | 193 } |
180 } | 194 } |
181 | 195 |
182 google::InitGoogleLogging("Orthanc"); | 196 google::InitGoogleLogging("Orthanc"); |
183 | 197 |