Split ncli across multiple files in its own directory
This commit is contained in:
48
modules/ncli/commands/git.nix
Normal file
48
modules/ncli/commands/git.nix
Normal file
@ -0,0 +1,48 @@
|
||||
# ncli/commands/git.nix — commit, push, pull, status, format
|
||||
lib:
|
||||
|
||||
let
|
||||
inherit (lib) project;
|
||||
in
|
||||
{
|
||||
commit_case = ''
|
||||
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
|
||||
if [ "$#" -lt 2 ]; then
|
||||
read -p "Enter commit message: " commit_msg
|
||||
else
|
||||
shift
|
||||
commit_msg="$*"
|
||||
fi
|
||||
|
||||
if [ -z "$commit_msg" ]; then
|
||||
echo "Error: Commit message cannot be empty" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git add -A && git commit -m "$commit_msg"
|
||||
;;
|
||||
'';
|
||||
|
||||
push_case = ''
|
||||
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
|
||||
git push origin $(git branch --show-current)
|
||||
;;
|
||||
'';
|
||||
|
||||
pull_case = ''
|
||||
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
|
||||
git pull origin $(git branch --show-current)
|
||||
;;
|
||||
'';
|
||||
|
||||
status_case = ''
|
||||
cd "$HOME/${project}" || { echo "Error: Could not change to $HOME/${project}"; exit 1; }
|
||||
git status
|
||||
;;
|
||||
'';
|
||||
|
||||
format_case = ''
|
||||
nix fmt .
|
||||
;;
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user