#!/bin/bash
# dev/package/cli - package CLI

set -e

lib_load 'dev/package/load'


######
# Package CLI

package_cli_dispatch() { lib_cmd_dispatch package_cli "$@"; }

package_cli_usage() {
	cat <<USAGE
<cmd> ...
Package Commands:
	config				Prints the package configuration
	dist ...			Generates package distribution files
	version ...			Package version commands
	license ...			Package license commands
	release ...			Package release commands
	publish ...			Package publishing commands
	install ...			Package installation commands
USAGE
}


######
# Package Configuration and Distribution

package_cli_config() {
	lib_load 'dev/package/config'
	package_config "$@"
}

package_cli_dist() {
	lib_load 'dev/package/dist'
	package_dist "$@"
}


######
# Package Version CLI

package_cli_version() {
	lib_load 'dev/package/versions'
	if [ "$*" ]; then
		cmd_dispatch "$@"
	else
		package_version_read
	fi
}

package_cli_version_usage() {
	cat <<USAGE
[<cmd> ...]
Package Version Commands:
	[show]				Prints the package version
	bump (micro|minor|major)	Bumps package version and commit
	unbump				Drops the version bump commit at HEAD
	tag 				Creates a new version tag

Note: These are emergency commands.  Use 'package release' instead.
USAGE
}

package_cli_version_bump() { package_version_bump "$@"; }
package_cli_version_unbump() { package_version_unbump "$@"; }

package_cli_version_tag() { package_version_tag "$@"; }
package_cli_version_untag() { package_version_untag "$@"; }


######
# Package Releases

package_cli_release() {
	lib_load 'dev/package/release'
	cmd_dispatch "$@"
}

package_cli_release_usage() {
	cat <<USAGE
[<cmd> ...]
Package Release Commands:
	(major|minor|micro)		Creates a new public release
	site-(major|minor|micro)	Creates a new site release
	undo				Reverts a just-made release

Individual Steps:
	ready				Verifies the release is ready
	tag				Creates the new tag
USAGE
}

package_cli_release_help() {
	local cmd=${script_name[*]}
	cat <<HELP
The '$cmd wizard' command does several things:
	* Verifies the package is ready for release
	* Produce a new tag for the current package version
	* Increments the version for development of the next release
HELP
}

package_cli_release_micro() { run package_release micro; }
package_cli_release_minor() { run package_release minor; }
package_cli_release_major() { run package_release major; }

package_cli_release_ready() {
	local not=''
	package_release_ready || not=' NOT'
	local func=app_echo
	[ -z "$not" ] || func=error
	$func "$PKG: package is$not ready to release"
}

package_cli_release_tag() { package_release_tag "$@"; }
package_cli_release_undo() { package_release_undo "$@"; }


######
# Package Publishing

package_cli_publish() {
	lib_load 'dev/package/publish'
	cmd_dispatch "$@"
}

package_cli_publish_usage() {
	cat <<USAGE
<cmd> [...]
Package Publishing Commands:
	master				Pushes to origin repository
	github				Pushes to GitHub repository
	release ...			Commands to publish release files
USAGE
}

package_cli_publish_master() { package_publish_git_remote origin; }
package_cli_publish_github() { package_publish_git_remote github ; }


######
# Package Release Publishing

package_cli_publish_release() { cmd_dispatch "$@"; }

package_cli_publish_release_usage() {
	cat <<USAGE
<cmd> [...]
Package Release Publishing Commands:
	all <version>			Performs all publishing steps
	tarballs <version>		Pushes tarballs to release server
	docs <version>			Pushes documentation to release server
	announce <version>		Publishes a release announcement
USAGE
}

package_cli_publish_release_all() {
	has_args 1 "$@"
	package_publish_tarballs "$@"
	package_publish_docs "$@"
	package_publish_announce "$@"
}

package_cli_publish_release_tarballs() { package_publish_tarballs "$@"; }
package_cli_publish_release_docs() { package_publish_docs "$@"; }
package_cli_publish_release_announce() { package_publish_announce "$@"; }


######
# Package Installation

package_cli_install() {
	lib_load 'dev/package/install'
	cmd_dispatch "$@"
}

package_cli_install_usage() {
	cat <<USAGE
<cmd>
Package Installation Commands:
	local <vers>			Installs the package locally
	remote <vers> <host>+		Installs on the remote host(s)
	script ...			Commands to generate installer scripts
USAGE
}

package_cli_install_local() { package_install_local "$@"; }
package_cli_install_remote() { package_install_remote "$@"; }


######
# Package Installer Scripts

package_cli_install_script() { cmd_dispatch "$@"; }

package_cli_install_script_usage() {
	cat <<USAGE
<cmd>
Package Installer Script Commands:
	local <vers> 			Prints local installer script
	remote <vers> 			Prints remote installer script
	network <vers> 			Prints network installer script
USAGE
}

package_cli_install_script_local() { package_install_script_local "$@"; }
package_cli_install_script_remote() { package_install_script_remote "$@"; }
package_cli_install_script_network() { package_install_script_net "$@"; }

View the Script Reference Index


Generated on Tue Apr 25 21:20:33 PDT 2017 by mcsh i7 v0.18.0.