131{
132 Gnucash::CoreApp::start();
133
134 if (!m_quotes_cmd.empty())
135 {
136 if (m_quotes_cmd.front() == "info")
137 {
138 return Gnucash::check_finance_quote ();
139 }
140 else if (m_quotes_cmd.front() == "get")
141 {
142 if (!m_file_to_load && m_quotes_cmd.size() == 2)
143 m_file_to_load = m_quotes_cmd[1];
144
145 if (!m_file_to_load || m_file_to_load->empty())
146 {
147 std::cerr << bl::translate("Missing data file parameter") << "\n\n"
148 << *m_opt_desc_display.get() << std::endl;
149 return 1;
150 }
151 else
152 return Gnucash::add_quotes (m_file_to_load);
153 }
154 else if (m_quotes_cmd.front() == "dump")
155 {
156 if (m_quotes_cmd.size() < 3 ||
157 (m_quotes_cmd[1] == "currency" &&
158 m_quotes_cmd.size() < 4))
159 {
160 std::cerr << bl::translate("Not enough information for quotes dump") << std::endl;
161 return 1;
162 }
163 auto source = m_quotes_cmd[1];
164 m_quotes_cmd.erase(m_quotes_cmd.begin(), m_quotes_cmd.begin() + 2);
165 return Gnucash::report_quotes(source.c_str(), m_quotes_cmd,
166 m_verbose);
167 }
168 else
169 {
170 std::cerr << bl::format (bl::translate("Unknown quotes command '{1}'")) % m_quotes_cmd.front() << "\n\n"
171 << *m_opt_desc_display.get() << std::endl;
172 return 1;
173 }
174 }
175
176 if (m_report_cmd)
177 {
178 if (*m_report_cmd == "run")
179 {
180 if (!m_file_to_load || m_file_to_load->empty())
181 {
182 std::cerr <<
_(
"Missing data file parameter") <<
"\n\n"
183 << *m_opt_desc_display.get() << std::endl;
184 return 1;
185 }
186 else
187 return Gnucash::run_report(m_file_to_load, m_report_name,
188 m_export_type, m_output_file);
189 }
190
191
192
193
194
195
196 else if (*m_report_cmd == "list")
197 return Gnucash::report_list ();
198
199
200
201
202
203 else if (*m_report_cmd == "show")
204 if (!m_report_name || m_report_name->empty())
205 {
206 std::cerr <<
_(
"Missing --name parameter") <<
"\n\n"
207 << *m_opt_desc_display.get() << std::endl;
208 return 1;
209 }
210 else
211 return Gnucash::report_show (m_file_to_load, m_report_name);
212 else
213 {
214 std::cerr << bl::format (std::string{
_(
"Unknown report command '{1}'")}) % *m_report_cmd <<
"\n\n"
215 << *m_opt_desc_display.get();
216 return 1;
217 }
218 }
219
220 std::cerr <<
_(
"Missing command or option") <<
"\n\n"
221 << *m_opt_desc_display.get() << std::endl;
222
223 return 1;
224}