Mercurial > hg > orthanc
comparison OrthancServer/Sources/main.cpp @ 4412:68b96234fbd6
automated generation of the cheat sheet of the REST API, to be included in the Orthanc Book
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 28 Dec 2020 11:57:48 +0100 |
parents | ad646ff506d0 |
children | 22a1352a0823 |
comparison
equal
deleted
inserted
replaced
4411:1d93700f5e23 | 4412:68b96234fbd6 |
---|---|
659 << "\t\t\tincompatible with former versions of Orthanc)" << std::endl | 659 << "\t\t\tincompatible with former versions of Orthanc)" << std::endl |
660 << " --no-jobs\t\tdon't restart the jobs that were stored during" << std::endl | 660 << " --no-jobs\t\tdon't restart the jobs that were stored during" << std::endl |
661 << "\t\t\tthe last execution of Orthanc" << std::endl | 661 << "\t\t\tthe last execution of Orthanc" << std::endl |
662 << " --openapi=[file]\twrite the OpenAPI documentation and exit" << std::endl | 662 << " --openapi=[file]\twrite the OpenAPI documentation and exit" << std::endl |
663 << "\t\t\t(if \"file\" is \"-\", dumps to stdout)" << std::endl | 663 << "\t\t\t(if \"file\" is \"-\", dumps to stdout)" << std::endl |
664 << " --cheatsheet=[file]\twrite the cheat sheet of REST API as CSV" << std::endl | |
665 << "\t\t\tand exit (if \"file\" is \"-\", dumps to stdout)" << std::endl | |
664 << " --version\t\toutput version information and exit" << std::endl | 666 << " --version\t\toutput version information and exit" << std::endl |
665 << std::endl | 667 << std::endl |
666 << "Fine-tuning of log categories:" << std::endl; | 668 << "Fine-tuning of log categories:" << std::endl; |
667 | 669 |
668 for (size_t i = 0; i < Logging::GetCategoriesCount(); i++) | 670 for (size_t i = 0; i < Logging::GetCategoriesCount(); i++) |
1791 { | 1793 { |
1792 LOG(ERROR) << "Cannot export OpenAPI documentation as file \"" << target << "\""; | 1794 LOG(ERROR) << "Cannot export OpenAPI documentation as file \"" << target << "\""; |
1793 return -1; | 1795 return -1; |
1794 } | 1796 } |
1795 } | 1797 } |
1798 else if (boost::starts_with(argument, "--cheatsheet=")) | |
1799 { | |
1800 std::string target = argument.substr(13); | |
1801 | |
1802 try | |
1803 { | |
1804 std::string cheatsheet; | |
1805 | |
1806 { | |
1807 SQLiteDatabaseWrapper inMemoryDatabase; | |
1808 inMemoryDatabase.Open(); | |
1809 MemoryStorageArea inMemoryStorage; | |
1810 ServerContext context(inMemoryDatabase, inMemoryStorage, true /* unit testing */, 0 /* max completed jobs */); | |
1811 OrthancRestApi restApi(context, false /* no Orthanc Explorer */); | |
1812 //restApi.GenerateReStructuredTextCheatSheet(cheatsheet, "https://api.orthanc-server.com/index.html"); | |
1813 restApi.GenerateReStructuredTextCheatSheet(cheatsheet, "http://localhost:8000/a.html"); | |
1814 context.Stop(); | |
1815 } | |
1816 | |
1817 if (target == "-") | |
1818 { | |
1819 std::cout << cheatsheet; // Print to stdout | |
1820 } | |
1821 else | |
1822 { | |
1823 SystemToolbox::WriteFile(cheatsheet, target); | |
1824 } | |
1825 return 0; | |
1826 } | |
1827 catch (OrthancException&) | |
1828 { | |
1829 LOG(ERROR) << "Cannot export REST cheat sheet as file \"" << target << "\""; | |
1830 return -1; | |
1831 } | |
1832 } | |
1796 else | 1833 else |
1797 { | 1834 { |
1798 LOG(WARNING) << "Option unsupported by the core of Orthanc: " << argument; | 1835 LOG(WARNING) << "Option unsupported by the core of Orthanc: " << argument; |
1799 } | 1836 } |
1800 } | 1837 } |