aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-02-14 01:18:39 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-02-14 01:19:32 +0100
commit38ebe658263fe5222ecf3c9fcd6322b9a8294663 (patch)
treed5e58d26f9329721dd6af0ae752ac187f42744b7
parent600b006f4b66b56284595f42511a1a6a03925d37 (diff)
downloadjson-rpc-shell-38ebe658263fe5222ecf3c9fcd6322b9a8294663.tar.gz
json-rpc-shell-38ebe658263fe5222ecf3c9fcd6322b9a8294663.tar.xz
json-rpc-shell-38ebe658263fe5222ecf3c9fcd6322b9a8294663.zip
Add manpage generation, update README
-rw-r--r--CMakeLists.txt25
-rw-r--r--README17
-rw-r--r--json-rpc-shell.c2
3 files changed, 38 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 23b7ea4..d63f3ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,6 +36,30 @@ include (GNUInstallDirs)
install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
+# Generate documentation from program help
+find_program (HELP2MAN_EXECUTABLE help2man)
+if (NOT HELP2MAN_EXECUTABLE)
+ message (FATAL_ERROR "help2man not found")
+endif (NOT HELP2MAN_EXECUTABLE)
+
+foreach (page ${PROJECT_NAME})
+ set (page_output "${PROJECT_BINARY_DIR}/${page}.1")
+ list (APPEND project_MAN_PAGES "${page_output}")
+ add_custom_command (OUTPUT ${page_output}
+ COMMAND ${HELP2MAN_EXECUTABLE} -N
+ "${PROJECT_BINARY_DIR}/${page}" -o ${page_output}
+ DEPENDS ${page}
+ COMMENT "Generating man page for ${page}" VERBATIM)
+endforeach (page)
+
+add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES})
+
+foreach (page ${project_MAN_PAGES})
+ string (REGEX MATCH "\\.([0-9])" manpage_suffix "${page}")
+ install (FILES "${page}"
+ DESTINATION "${CMAKE_INSTALL_MANDIR}/man${CMAKE_MATCH_1}")
+endforeach (page)
+
# CPack
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Shell for JSON-RPC 2.0 HTTP queries")
set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
@@ -53,4 +77,3 @@ set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${project_VERSION}")
include (CPack)
-
diff --git a/README b/README
index 0b8d43d..1d0ba87 100644
--- a/README
+++ b/README
@@ -10,16 +10,25 @@ Fuck Java. With a sharp, pointy object. In the ass. Hard. json-c as well.
Building and Running
--------------------
-Build dependencies: CMake, pkg-config, libev, Jansson, cURL, readline
+Build dependencies: CMake, pkg-config, help2man, libev, Jansson, cURL, readline
$ git clone https://github.com/pjanouch/json-rpc-shell.git
$ mkdir build
$ cd build
- $ cmake .. -DCMAKE_BUILD_TYPE=Debug
+ $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug
$ make
-Now you can run the following command to get some help about the exact usage:
- $ ./json-rpc-shell --help
+To install the application, you can do either the usual:
+ $ make install
+
+Or you can try telling CMake to make a package for you. For Debian it is:
+ $ cpack -G DEB
+ # dpkg -i json-rpc-shell-*.deb
+
+Note that for versions of CMake before 2.8.9, you need to prefix cpack with
+`fakeroot' or file ownership will end up wrong.
+
+Run the program with `--help' to obtain usage information.
License
-------
diff --git a/json-rpc-shell.c b/json-rpc-shell.c
index 5fd4b4e..71f99c9 100644
--- a/json-rpc-shell.c
+++ b/json-rpc-shell.c
@@ -605,7 +605,7 @@ on_tty_readable (EV_P_ ev_io *handle, int revents)
static void
print_usage (const char *program_name)
{
- fprintf (stderr,
+ fprintf (stdout,
"Usage: %s [OPTION]... ENDPOINT\n"
"Trivial JSON-RPC shell.\n"
"\n"