Skip to content

Commit

Permalink
fix #131: add build time option: CLIENT_PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
m6w6 committed Feb 28, 2023
1 parent 94b05fd commit dacded4
Show file tree
Hide file tree
Showing 24 changed files with 169 additions and 106 deletions.
3 changes: 3 additions & 0 deletions CMakeConfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ else()
set(TARGET_NAMELINK_COMPONENT NAMELINK_COMPONENT dev DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

set(CLIENT_PREFIX mem
CACHE STRING "client prefix (default mem; i.e.: memstat, memcp, memcat ...)")

option(BUILD_SHARED_LIBS "whether to build shared libraries"
ON)
option(BUILD_TESTING "whether to enable build of the test suite"
Expand Down
26 changes: 13 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ if(NOT BUILD_DOCSONLY)
include(CMake/_Include.cmake)

set(CLIENTS
memcapable
memcat
memcp
memdump
memerror
memexist
memflush
memparse
memping
memrm
memslap
memstat
memtouch
capable
cat
cp
dump
error
exist
flush
parse
ping
rm
slap
stat
touch
)

add_subdirectory(include)
Expand Down
4 changes: 2 additions & 2 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ else()
COMMAND
${CMAKE_COMMAND} -E touch "${SPHINX_HTML_DIR}"
BYPRODUCTS ${SPHINX_HTML_DIR}
DEPENDS "${DOCS_SOURCE}"
DEPENDS "${DOCS_SOURCE}" conf.py.in
)
add_custom_target(html ALL DEPENDS "${SPHINX_HTML_DIR}")

Expand All @@ -73,7 +73,7 @@ else()
COMMAND
${CMAKE_COMMAND} -E touch "${SPHINX_MAN_DIR}"
BYPRODUCTS ${SPHINX_MAN_DIR}
DEPENDS "${DOCS_SOURCE}"
DEPENDS "${DOCS_SOURCE}" conf.py.in
)
add_custom_target(man ALL DEPENDS "${SPHINX_MAN_DIR}")

Expand Down
55 changes: 37 additions & 18 deletions docs/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,46 @@ man_pages = [
('libmemcachedutil/memcached_pool' ,'memcached_pool_st' ,u'libmemcached Documentation' ,man_authors,3),
('libmemcachedutil/memcached_pool' ,'memcached_pool' ,u'libmemcached Documentation' ,man_authors,3),

('bin/memcapable' , 'memcapable' , u'libmemcached Documentation' , man_authors, 1),
('bin/memcat' , 'memcat' , u'libmemcached Documentation' , man_authors, 1),
('bin/memcp' , 'memcp' , u'libmemcached Documentation' , man_authors, 1),
('bin/memdump' , 'memdump' , u'libmemcached Documentation' , man_authors, 1),
('bin/memerror' , 'memerror' , u'libmemcached Documentation' , man_authors, 1),
('bin/memflush' , 'memflush' , u'libmemcached Documentation' , man_authors, 1),
('bin/memrm' , 'memrm' , u'libmemcached Documentation' , man_authors, 1),
('bin/memaslap' , 'memaslap' , u'libmemcached Documentation' , man_authors, 1),
('bin/memslap' , 'memslap' , u'libmemcached Documentation' , man_authors, 1),
('bin/memstat' , 'memstat' , u'libmemcached Documentation' , man_authors, 1),
('bin/memexist' , 'memexist' , u'libmemcached Documentation' , man_authors, 1),
('bin/memparse' , 'memparse' , u'libmemcached Documentation' , man_authors, 1),
('bin/memping' , 'memping' , u'libmemcached Documentation' , man_authors, 1),
('bin/memtouch' , 'memtouch' , u'libmemcached Documentation' , man_authors, 1),
('bin/memcapable' , 'memcapable' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memcat' , 'memcat' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memcp' , 'memcp' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memdump' , 'memdump' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memerror' , 'memerror' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memflush' , 'memflush' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memrm' , 'memrm' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memaslap' , 'memaslap' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memslap' , 'memslap' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memstat' , 'memstat' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memexist' , 'memexist' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memparse' , 'memparse' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memping' , 'memping' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memtouch' , 'memtouch' ,u'libmemcached Documentation' , man_authors, 1),
]

if '@CLIENT_PREFIX@' != 'mem' :
man_pages.extend([
('bin/memcapable' , '@CLIENT_PREFIX@capable' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memcat' , '@CLIENT_PREFIX@cat' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memcp' , '@CLIENT_PREFIX@cp' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memdump' , '@CLIENT_PREFIX@dump' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memerror' , '@CLIENT_PREFIX@error' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memflush' , '@CLIENT_PREFIX@flush' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memrm' , '@CLIENT_PREFIX@rm' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memaslap' , '@CLIENT_PREFIX@aslap' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memslap' , '@CLIENT_PREFIX@slap' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memstat' , '@CLIENT_PREFIX@stat' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memexist' , '@CLIENT_PREFIX@exist' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memparse' , '@CLIENT_PREFIX@parse' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memping' , '@CLIENT_PREFIX@ping' ,u'libmemcached Documentation' , man_authors, 1),
('bin/memtouch' , '@CLIENT_PREFIX@touch' ,u'libmemcached Documentation' , man_authors, 1),
])

rst_prolog = """
.. |libhashkit_version| replace:: 1.0
.. |libmemcached_version| replace:: 1.0
.. |libmemcachedprotocol_version| replace:: 0.0
.. |libmemcachedutil_version| replace:: 1.0
.. |client_prefix| replace:: @CLIENT_PREFIX@
.. |libhashkit_version| replace:: @LIBHASHKIT_VERSION_INC@
.. |libmemcached_version| replace:: @LIBMEMCACHED_VERSION_INC@
.. |libmemcachedprotocol_version| replace:: @LIBMEMCACHEDPROTOCOL_VERSION_INC@
.. |libmemcachedutil_version| replace:: @LIBMEMCACHEDUTIL_VERSION_INC@
"""

@SPHINX_CONF_APPEND@
7 changes: 7 additions & 0 deletions docs/source/bin/common/env.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ENVIRONMENT
-----------

.. envvar:: MEMCACHED_SERVERS

Specify a list of servers.

8 changes: 8 additions & 0 deletions docs/source/bin/common/note_contrib_options.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

CONTRIBUTED PROGRAM
...................

This is a contributed program.

This program doesn't follow the standard flag/option scheme.

10 changes: 10 additions & 0 deletions docs/source/bin/common/note_program_prefix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

PROGRAM PREFIX
..............

The prefix of this program is variable, i.e. it can be configured at build time.

Usually the client programs of ``libmemcached-awesome`` are prefixed with ``mem``, like ``memcat`` or ``memcp``.

It can be configured, though, to replace the prefix with something else like ``mc``, in case of that,
the client programs of ``libmemcached-awesome`` would be called ``mccat``, ``mccp``, etc. respectively.
12 changes: 5 additions & 7 deletions docs/source/bin/memaslap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ memaslap - Load testing and benchmarking a server
SYNOPSIS
--------

memaslap [options]
|client_prefix|\aslap [options]

.. program:: memaslap

Expand Down Expand Up @@ -1000,13 +1000,11 @@ memaslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m

memaslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m -p 2

NOTE
----

This is a contributed program.

This program doesn't follow the standard flag/option scheme.
NOTES
-----

.. include:: common/note_program_prefix.rst
.. include:: common/note_contrib_options.rst

SEE ALSO
--------
Expand Down
10 changes: 6 additions & 4 deletions docs/source/bin/memcapable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SYNOPSIS

.. program:: memcapable

memcapable [options]
|client_prefix|\capable [options]

Check a memcached server's capabilities and compatibility.

Expand Down Expand Up @@ -39,10 +39,12 @@ OPTIONS

Set the timeout for an IO operation to/from the server to \ *n*\ seconds.

NOTE
----

This program doesn't follow the standard flag/option scheme.
NOTES
-----

.. include:: common/note_program_prefix.rst
.. include:: common/note_contrib_options.rst


SEE ALSO
Expand Down
10 changes: 5 additions & 5 deletions docs/source/bin/memcat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SYNOPSIS

.. program:: memcat

memcat [options] key [key...]
|client_prefix|\cat [options] key [key...]

Read and output the value of one key or the values of a set of keys.

Expand All @@ -28,12 +28,12 @@ OPTIONS
.. include:: options/hash.rst
.. include:: options/file_out.rst

ENVIRONMENT
-----------
.. include:: common/env.rst

.. envvar:: MEMCACHED_SERVERS
NOTES
-----

Specify a list of servers.
.. include:: common/note_program_prefix.rst

SEE ALSO
--------
Expand Down
14 changes: 7 additions & 7 deletions docs/source/bin/memcp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SYNOPSIS

.. program:: memcp

memcp [options] \-\-servers <hostname[:port]...> <file...>
|client_prefix|\cp [options] \-\-servers <hostname[:port]...> <file...>

Copy files to a collection of memcached servers.

Expand Down Expand Up @@ -49,14 +49,14 @@ OPTIONS
.. option:: -/|--absolute

Use absolute path (real path), instead of basename only.


ENVIRONMENT
-----------

.. envvar:: MEMCACHED_SERVERS

Specify the list of servers.
.. include:: common/env.rst

NOTES
-----

.. include:: common/note_program_prefix.rst

SEE ALSO
--------
Expand Down
13 changes: 7 additions & 6 deletions docs/source/bin/memdump.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SYNOPSIS

.. program:: memdump

memdump [options]
|client_prefix|\dump [options]

Dump a list of keys from a server.

Expand All @@ -22,13 +22,14 @@ OPTIONS

.. include:: options/common_get.rst
.. include:: options/file_out.rst

ENVIRONMENT
-----------

.. envvar:: MEMCACHED_SERVERS

Specify the list of servers.
.. include:: common/env.rst

NOTES
-----

.. include:: common/note_program_prefix.rst

SEE ALSO
--------
Expand Down
11 changes: 6 additions & 5 deletions docs/source/bin/memerror.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SYNOPSIS

.. program:: memerror

memerror [options] <error code>
|client_prefix|\error [options] <error code>

Translate a memcached error code into a string.

Expand All @@ -22,12 +22,13 @@ OPTIONS
.. include:: options/all.rst
.. include:: options/common.rst

ENVIRONMENT
-----------

.. envvar:: MEMCACHED_SERVERS
.. include:: common/env.rst

NOTES
-----

Specify the list of servers.
.. include:: common/note_program_prefix.rst

SEE ALSO
--------
Expand Down
10 changes: 5 additions & 5 deletions docs/source/bin/memexist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SYNOPSIS

.. program:: memexist

memexist [options] <key>
|client_prefix|\exist [options] <key>

Check for the existence of a key.

Expand All @@ -21,12 +21,12 @@ OPTIONS
.. include:: options/common_get.rst
.. include:: options/hash.rst

ENVIRONMENT
-----------
.. include:: common/env.rst

.. envvar:: MEMCACHED_SERVERS
NOTES
-----

Specify the list of servers.
.. include:: common/note_program_prefix.rst

SEE ALSO
--------
Expand Down
11 changes: 6 additions & 5 deletions docs/source/bin/memflush.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ memflush
SYNOPSIS
--------

memflush [options]
|client_prefix|\flush [options]

.. program:: memflush

Expand Down Expand Up @@ -51,12 +51,13 @@ OPTIONS

.. _memcached protocol documentation: https://github.com/memcached/memcached/blob/master/doc/protocol.txt

ENVIRONMENT
-----------

.. envvar:: MEMCACHED_SERVERS
.. include:: common/env.rst

NOTES
-----

Specify the list of servers.
.. include:: common/note_program_prefix.rst

SEE ALSO
--------
Expand Down
8 changes: 7 additions & 1 deletion docs/source/bin/memparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SYNOPSIS

.. program:: memparse

memparse <option string>
|client_prefix|\parse <option string>

Parse and validate an option string.

Expand All @@ -20,6 +20,12 @@ OPTIONS

None.

NOTES
-----

.. include:: common/note_program_prefix.rst


SEE ALSO
--------

Expand Down
Loading

0 comments on commit dacded4

Please sign in to comment.