GitLab system status is available here and here

Commit b4dc0f53 authored by Anthony Umemoto's avatar Anthony Umemoto
Browse files

v1.3.0 presets

parent b02fb131
......@@ -15,25 +15,20 @@ A shell script for automated git repository management in the command line envir
## PROGRAM FILES
+ gitmang.sh: The shell script for automating git repository management.
+ create_preset.sh: The shell script used for creating new presets.
+ gm_usage.sh: Contains usage statements for gitmang programs.
+ .gm_usage.sh: Contains usage statements for gitmang.
+ presets.gm: Contains created presets.
+ UPDATE.md: Lists each version of gitmang, and what changes were made.
+ README.md: Explains how to use gitmang.
## USAGE
`$ ./gitmang.sh [-vsBh] [-p preset] [-dDR dir] [-b branch] [-f freq] [-r reps] [file1 file2 ...]`
`$ ./gitmang.sh [-vsBh] [-px preset] [-dDR dir] [-b branch] [-f freq] [-r reps] [file1 file2 ...]`
git must be installed, and gitmang should be run in a UNIX or git bash terminal. gitmang is currently untested in other terminals such as the Windows command prompt, and the macOS terminal. To give executing permissions use:
`$ chmod +x gitmang.sh`
`$ chmod +x gitmang.sh` and `$chmod +x .gm_usage.sh`
gitmang requires that a terminal window is dedicated to running it. Open a new terminal with:
`$ ssh <username>@localhost -p <port>`
Or open a new git bash window in your gitmang local repository.
gitmang requires that a terminal window is dedicated to running it.
When quitting the program, use the 'q' runtime option to quit properly. Always remember to quit properly before turning off your machine. If gitmang is unexpectedly ended while it is performing a commit, the local repository may become corrupt. If this happens, use the [-R dir] command to repair the local repository to save un-committed work. However, this command only works if the remote repository URL is uncorrupted. To test if it is, use:
......@@ -41,15 +36,31 @@ When quitting the program, use the 'q' runtime option to quit properly. Always r
If the correct URL is returned, then the repair should work.
To make gitmang a more convenient tool to use, presets can be made with the [-p preset] command line option, so that it doesn't require you to repeatedly type the same commands for a project repository you work in often. For example:
`13s_asgn4 -v -s -d ../cse13s/asgn4 -f 10 *.c *.h Makefile README.md`
is a preset that can be made for a cse13s class' assignment 4. This is how the preset will appear in the presets.gm file (preset name first, followed by its options), which contains all created presets and can be editted directly. While presets can be added by typing them into the presets.gm file by hand, it is recommended that the command line option is used instead, since it will check for erroneous input. This preset can then be used with the same [-p preset] option used to create it:
`$ ./gitmang.sh -p 13s_asgn4`
And can be deleted with the [-x preset] command line option:
`$ ./gitmang.sh -x 13s_asgn4`
## COMMAND LINE OPTIONS
### GITMANG.SH
`$ ./gitmang.sh [-vsBh] [-px preset] [-dDR dir] [-b branch] [-f freq] [-r reps] [file1 file2 ...]`
`-v` Display verbose program output.
`-s` Silence commit and push summaries.
`-p preset` Use preset gitmang options. Create a new preset if the name does not exist. Display all presets if no name is specified.
`-p preset` Use preset gitmang options. Create a new preset if the name does not exist. Display all presets if `ALL` is specified.
`-x preset` Delete the specified preset.
`-d dir` The file path, from the current working directory, to the repository being managed.
......@@ -69,26 +80,16 @@ If the correct URL is returned, then the repair should work.
`-h` Display program usage and synopsis.
### CREATE_PRESET.SH
`./create_preset.sh [-h] [-p preset] [-o outfile]`
`-p preset` The name of the preset to be made.
### .GM_USAGE.SH
`-o outfile` Specify an outfile to output the creaed preset to besides presets.gm. If no outfile is specified, output to stdout.
`./.gm_usage.sh [-hrp]`
`-h` Display program usage and synopsis.
### GM_USAGE.SH
`-h` Display gitmang usage and synopsis.
`./gm_usage.sh [-hrp]`
`-h` Only display gitmang command line options.
`-c` Only display gitmang command line options.
`-r` Only display gitmang runtime options.
`-p` Display create_preset.sh synopsis and usage.
## RUNTIME OPTIONS
`q` Quits the program.
......
......@@ -6,11 +6,10 @@ Most recent version is listed first.
+ Added the [-p preset] command line option.
+ Presets are a way to quickly set up gitmang with options that are regularly used.
+ If the preset name is already defined, then it gitmang will begin running using that preset. If the preset name is new, then a new preset will be created. If no preset name is specified, then the list of saved presets will be displayed.
+ If the preset name is already defined, then gitmang will begin running using that preset. If the preset name is new, then a new preset will be created. If no preset name is specified, then the list of saved presets will be displayed.
+ Added the [-x preset] command line option to delete to specified preset.
+ Added the presets.gm file, which contains all created presets. This file can be editted directly.
+ Added the gm_usage.sh script, which contains all usage messages for gitmang programs.
+ Added the create_preset.sh script, which is used to create presets. Users can use this script, or the [-p preset] command line option to create a new preset.
+ Minor documentation revisions.
### v1.2.1 March 24, 2022, 6:50 PDT
......
......@@ -17,44 +17,89 @@ gm_backup=0
gm_files=()
# process command line arguments
while getopts vsp:d:D:b:f:r:R:Bh opt; do
while getopts vsp:x:d:D:b:f:r:R:Bh opt; do
case "${opt}" in
v) gm_verb=1;; # verbose output
s) gm_sil="-q";; # silence summaries
p) # presets
if [[ ${OPTARG} == "" ]]; then # display all presets
if [[ ${OPTARG} == "ALL" ]]; then # display all presets
echo "Available presets:"
while read -r line < presets.gm; do
while read -r line; do
echo "$line"
done
done < presets.gm
exit
else
# look for preset
while read -r -a gm_preset < presets.gm; do
if [[ ${gm_preset[0]} == ${OPTARG} ]]; then
gm_i=0 # iterator so that
for gm_preopt in "${gm_preset[@]}"; do
case "gm_preopt" in
while read -r -a gm_preset; do
# if preset is found
if [[ "${gm_preset[0]}" == "${OPTARG}" ]]; then
echo "Preset ${gm_preset[*]}"
# parsing preset options
for (( gm_i=1; $gm_i < ${#gm_preset[@]}; gm_i+=1)); do
case "${gm_preset[$gm_i]}" in
"-v") gm_verb=1;;
"-s") gm_sil=1;;
"-d") gm_dir=${gm_preset[$((gm_i+1))]};;
"-D") gm_dir=${gm_preset[$((gm_i+1))]};;
"-b") gm_branch=${gm_preset[$((gm_i+1))]};;
"-f") gm_freq=${gm_preset[$((gm_i+1))]};;
"-r") gm_reps=${gm_preset[$((gm_i+1))]};;
*) gm_files+=(gm_preopt);;
"-d")
gm_dir=${gm_preset[$((gm_i+1))]}
((gm_i+=1));;
"-D")
gm_dir=${gm_preset[$((gm_i+1))]}
((gm_i+=1));;
"-b")
gm_branch=${gm_preset[$((gm_i+1))]}
((gm_i+=1));;
"-f")
gm_freq=${gm_preset[$((gm_i+1))]}
((gm_i+=1));;
"-r")
gm_reps=${gm_preset[$((gm_i+1))]}
((gm_i+=1));;
*) gm_files+=( "${gm_preset[$gm_i]}" );;
esac
((gm_i+=1))
done
fi
done
done < presets.gm
# create new preset, dir must be specified so if it is not
# then no preset was found
if [[ $gm_dir == "" ]]; then
./create_preset.sh
./.gm_usage.sh -c
echo ""
echo "Creating new preset ${OPTARG}."
read -p "Preset commands: " gm_preset
echo "${OPTARG} $gm_preset" >> presets.gm
echo "Preset ${OPTARG} created, use preset with ./gitmang.sh -p ${OPTARG}."
exit
fi
fi;;
x) # delete preset
if [[ ${OPTARG} == "" ]]; then
echo "A preset must be specified to delete."
else
# look for preset
gm_i=0
while read -r -a gm_preset; do
if [[ "${gm_preset[0]}" != "${OPTARG}" ]]; then
echo "${gm_preset[*]}" >> .preset_temp.gm
((gm_i+=1))
fi
done < presets.gm
# creates temp file in case there is only one preset
if (( $gm_i == 0 )); then
echo > .preset_temp.gm
fi
# replaces old presets file
mv .preset_temp.gm presets.gm
echo "Preset ${OPTARG} has been deleted."
fi
exit;;
d) gm_dir=${OPTARG};; # repo directory from working dir
......@@ -86,10 +131,10 @@ while getopts vsp:d:D:b:f:r:R:Bh opt; do
B) gm_backup=1;; # keep backup
h) # program usage and synopsis
./gm_usage.sh -h
./.gm_usage.sh -h
exit;;
*)
./gm_usage.sh -h
./.gm_usage.sh -h
exit;;
esac
done
......@@ -377,7 +422,7 @@ while (( $gm_reps > 0 )); do
echo "Current file names in the commit list:"
echo "${gm_files[*]}";;
h) ./gm_usage.sh -r;; # runtime options
h) ./.gm_usage.sh -r;; # runtime options
*) echo "Failed to execute runtime command.";;
esac
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment