[pve-devel] [RFC zsync 1/2] do not duplicate common docs for CLI help and manpage

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Mar 9 16:55:42 CET 2018


add a hidden command which prints the POD of pve-zsync, reusing the
documentation for pve-zsync help CMD

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 Makefile  |   2 +-
 pve-zsync | 125 +++++++++-----------------------------------------------------
 2 files changed, 19 insertions(+), 108 deletions(-)
 mode change 100644 => 100755 pve-zsync

diff --git a/Makefile b/Makefile
index 9879dc4..6317308 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ dinstall: deb
 	gzip -n pve-zsync.8.man -c9 >$@
 
 pve-zsync.8.man: pve-zsync
-	pod2man -c "Proxmox Documentation" -s 8 -r ${RELEASE} -n pve-zsync  pve-zsync pve-zsync.8.man
+	./pve-zsync printpod | pod2man -c "Proxmox Documentation" -s 8 -r ${RELEASE} -n pve-zsync - pve-zsync.8.man
 
 .PHONY: install
 install: pve-zsync.8.man pve-zsync.8.gz
diff --git a/pve-zsync b/pve-zsync
old mode 100644
new mode 100755
index 2503117..20b15b2
--- a/pve-zsync
+++ b/pve-zsync
@@ -1017,7 +1017,9 @@ my $commands = {'destroy' => 1,
 		'status' => 1,
 		'help' => 1,
 		'enable' => 1,
-		'disable' => 1};
+		'disable' => 1,
+		'printpod' => 1,
+};
 
 if (!$command || !$commands->{$command}) {
     usage();
@@ -1240,6 +1242,8 @@ if ($command eq 'destroy') {
     check_target($param->{source});
     disable_job($param);
 
+} elsif ($command eq 'printpod') {
+    print_pod();
 }
 
 sub usage {
@@ -1262,8 +1266,8 @@ sub check_target {
     parse_target($target);
 }
 
-__END__
-
+sub print_pod {
+    print <<EOF;
 =head1 NAME
 
 pve-zsync - PVE ZFS Replication Manager
@@ -1272,117 +1276,21 @@ pve-zsync - PVE ZFS Replication Manager
 
 pve-zsync <COMMAND> [ARGS] [OPTIONS]
 
-pve-zsync help <cmd> [OPTIONS]
+$help_help
 
-	Get help about specified command.
+$help_create
 
-        <cmd>      string
+$help_destroy
 
-		Command name
+$help_disable
 
-	-verbose   boolean
+$help_enable
 
-		Verbose output format.
+$help_list
 
-pve-zsync create -dest <string> -source <string> [OPTIONS]
+$help_status
 
-        Create a sync Job
-
-        -dest      string
-
-		the destination target is like [IP]:<Pool>[/Path]
-
-        -limit     integer
-
-		max sync speed in kBytes/s, default unlimited
-
-        -maxsnap   string
-
-		how much snapshots will be kept before get erased, default 1
-
-        -name      string
-
-		name of the sync job, if not set it is default
-
-        -skip      boolean
-
-		if this flag is set it will skip the first sync
-
-        -source    string
-
-		the source can be an <VMID> or [IP:]<ZFSPool>[/Path]
-
-pve-zsync destroy -source <string> [OPTIONS]
-
-        remove a sync Job from the scheduler
-
-        -name      string
-
-		name of the sync job, if not set it is default
-
-        -source    string
-
-                the source can be an  <VMID> or [IP:]<ZFSPool>[/Path]
-
-pve-zsync disable -source <string> [OPTIONS]
-
-        pause a sync job
-
-        -name      string
-
-		name of the sync job, if not set it is default
-
-        -source    string
-
-                the source can be an  <VMID> or [IP:]<ZFSPool>[/Path]
-
-pve-zsync enable -source <string> [OPTIONS]
-
-        enable a syncjob and reset error
-
-        -name      string
-
-		name of the sync job, if not set it is default
-
-        -source    string
-
-                the source can be an  <VMID> or [IP:]<ZFSPool>[/Path]
-pve-zsync list
-
-	Get a List of all scheduled Sync Jobs
-
-pve-zsync status
-
-	Get the status of all scheduled Sync Jobs
-
-pve-zsync sync -dest <string> -source <string> [OPTIONS]
-
-	will sync one time
-
-        -dest      string
-
-		the destination target is like [IP:]<Pool>[/Path]
-
-	-limit     integer
-
-		max sync speed in kBytes/s, default unlimited
-
-        -maxsnap   integer
-
-		how much snapshots will be kept before get erased, default 1
-
-        -name      string
-
-		name of the sync job, if not set it is default.
-		It is only necessary if scheduler allready contains this source.
-
-        -source    string
-
-		the source can be an <VMID> or [IP:]<ZFSPool>[/Path]
-
-	-verbose   boolean
-
-		print out the sync progress.
+$help_sync
 
 =head1 DESCRIPTION
 
@@ -1423,3 +1331,6 @@ Affero General Public License for more details.
 You should have received a copy of the GNU Affero General Public
 License along with this program.  If not, see
 <http://www.gnu.org/licenses/>.
+
+EOF
+}
-- 
2.14.2





More information about the pve-devel mailing list