Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

nushell/modules/sy.nu

Raw
# Check system status
export def main [] {
	check-deps
	let git_status_dotfiles = [ '-C' $env.DOTFILES status '--short' '--branch' ]
	run-external git ...$git_status_dotfiles
	macchina
}

# Synchronize by uploading
export def up [] {
	check-deps

	let git_add_dotfiles = [ '-C' $env.DOTFILES add '--all' ]
	let git_commit_dotfiles = [ '-C' $env.DOTFILES commit '--all' ]
	let git_push_dotfiles = [ '-C' $env.DOTFILES push ]

	run-external git ...$git_add_dotfiles
	try { run-external git ...$git_commit_dotfiles }
	run-external git ...$git_push_dotfiles
}

# Synchronise by downloading
export def down [] {
	check-deps
	let git_pull_dotfiles = [ '-C' $env.DOTFILES pull ]
	run-external git ...$git_pull_dotfiles
	run-external topgrade
}

def all-exist [] { all { which $in | is-not-empty } }

def check-deps [] {
	let deps = [ git topgrade macchina ]
	if not ($deps | all-exist) {
		error make {
			msg: $"Install all of ($deps)"
		}
	}
}