#!/bin/bash
#  d12 - Development helper

set -e

source "/home/zwelch/src/mcf/mcsh-release/install/share/mcsh/mcsh.sh"


######
# Source Code Generation

d12_gen() { cmd_dispatch "$@"; }
d12_gen_usage() {
	cat <<USAGE
...
Source Code Generation:
	bash ...			Bash script generation
	python ...			Python script generation
USAGE
}

d12_gen_bash() {
	lib_load 'dev/gen/bash'
	gen_bash_dispatch "$@"
}

d12_gen_python() { error "not implemented"; }


######
# Source code symbols

d12_sym() {
	lib_load 'dev/package/cli'
	lib_cmd_dispatch package_cli_sym "$@"
}


######
# Source code introspection CLI

d12_wc() {
	lib_load 'dev/package/search'
	package_wc "$@"
}
d12_grep() {
	lib_load 'dev/package/search'
	package_grep "$@"
}

######
# Source code transformation CLI

d12_sed() {
	lib_load 'dev/package/edit'
	package_sed "$@"
}



######
# Dependency CLI

d12_dep() {
	lib_load 'dev/package/dep'
	package_dep_dispatch "$@"
}


######
# Source file commands

d12_files() {
	lib_load 'dev/package/files'
	local cmd=$1
	case "$cmd" in
	(dist|package|source|configs|tools|libs|extension) package_files "$@" ;;
	(all) with_package_files "$@" ;;
	(each) with_each_package_file "$@" ;;
	(*) error_usage "$cmd: unknown source file command" ;;
	esac
}

d12_files_usage() {
	cat <<USAGE
Source File Commands:
	dist				Prints contents of distribution package
	package				Prints all of the package source files
	source				Prints all of the source code files
	configs				Prints tool configuration file names
	tools				Prints tool source code file names
	libs				Prints library source code file names

Source Iteration Commands:
	all <kind> <cmd> [<opts>]	Runs a command with all source files
	each <kind> <cmd> [<opts>]	Runs a command for each source file
USAGE
}


######
# Tool Development CLI

d12_tool() {
	lib_load 'dev/package/load'
	cmd_dispatch "$@"
}

d12_tool_usage() {
	cat <<USAGE
Tool Development Commands:
	cats 				Prints categories of all package apps
	names 				Prints tool names of all package apps
	rename <oldname> <newname>	Renames a tool script (and its .conf)
USAGE
}

d12_tool_cats() { tool_cats "${APPS[@]}"; }
d12_tool_names() { tool_names "${APPS[@]}"; }
d12_tool_rename() {
	lib_load 'dev/package/edit'
	package_file_rename tools "$@"
}


######
# Library Development CLI

d12_lib() { cmd_dispatch "$@"; }

d12_lib_usage() {
	cat <<USAGE
Library Development Commands:
	rename <oldname> <newname>	Renames a library script
USAGE
}

d12_lib_rename() {
	lib_load 'dev/package/edit'
	package_file_rename libs "$@"
}


######
# Main

d12_desc() { echo "Development helper"; }

d12_usage() {
	cat <<USAGE
<cmd> ...
Introspection Commands:
	wc [<opts>]			Runs wc on all source code files
	grep <pattern> [<opts>]		Runs grep on all source code files

Manipulation Commands:
	sed <old> <new>			Runs sed on all source code files

Component Commands:
	dep ...				Component dependency commands
	gen ...				Component generation commands

Source Code File Commands:
	sym ...				Source code symbol commands
	files ...			Source code file commands
	tool ...			Tool development commands
	lib ...				Library development commands
USAGE
}

app_run "$@"

View the Developer Guide Index

View the Reference Manual Index


Generated on Fri Jul 28 14:34:23 PDT 2017 by mcsh d14 v0.23.0.