#!/usr/bin/env bash
#
# Show help for Cogito commands.
# Copyright (c) Petr Baudis, 2005
#
# Takes an optional argument describing the command to show the help for.
# The command can be specified either as 'COMMAND' or 'cg-COMMAND'.
# If the argument is left out an overview of all the Cogito commands will
# be shown.
#
# Note help for a command is also available by passing `--help` or `-h`
# to the command.

USAGE="cg-help [COMMAND]"
_git_repo_unneeded=1

. ${COGITO_LIB}cg-Xlib


if [ "$1" ]; then
	cmd=$(echo "$1" | sed 's/^cg-//')
	( print_help $cmd ) && exit
	echo "cg-help: no help available for command \"$1\""
	echo "Call cg-help without any arguments for the list of available commands"
	exit 1
fi


cat <<__END__
The Cogito version control system  $(cg-version)

Usage: cg-COMMAND [ARG]...

Available commands:
	cg-add		FILE...
	cg-branch-add	BNAME SOURCE_LOC
	cg-branch-ls
	cg-cancel
	cg-clone	[-s] SOURCE_LOC [DESTDIR]
	cg-commit	[-m"Commit message"]... [-e | -E] [FILE]... < log message
	cg-diff		[-c] [-m] [-p] [-r FROM_ID[:TO_ID]] [FILE]...
	cg-export	DEST [TREE_ID]
	cg-help		[COMMAND]
	cg-init
	cg-log		[-c] [-f] [-m] [-r FROM_ID[:TO_ID]] [FILE]...
	cg-merge	[-c] [-b BASE_ID] FROM_ID
	cg-mkpatch	[-m] [-s] [-r FROM_ID[:TO_ID]]
	cg-patch			< patch on stdin
	cg-pull		[BNAME]
	cg-restore	[FILE]...
	cg-rm		FILE...
	cg-seek		[COMMIT_ID]
	cg-status
	cg-tag		TNAME [COMMIT_ID]
	cg-tag-ls
	cg-update	[BNAME]
	cg-version

Advanced (low-level or dangerous) commands:
	cg-admin-ls	[-t TREE_ID] [PATH]
	cg-admin-lsobj	[OBJTYPE]
	cg-admin-uncommit [-t] [COMMIT_ID]

These expressions can be used interchangably as "ID"s:
	empty string, "this" or "HEAD" (current HEAD)
	branch name (as registered with cg-branch-add)
	tag name (as registered with cg-tag)
	date string (as recognized by the date tool)
	shortcut hash (shorted unambiguous hash lead)
	commit object hash (as returned by commit-id)
	tree object hash (accepted only by some commands)

For details on individual commands, do e.g.:
	cg-help cg-log
	cg-log --help
(both variants are equivalent)
__END__
