<commit_before>#!/usr/bin/env bash

## Variables ##

# Set first first arg[] as <command>
comm=$1

# Set Version Number
version="v0.4.1"

## Functions ##

# Help Header
helphead(){
	echo $version
	echo "Usage: snapt <command>"
	echo ""
	echo "Snapt is a script designed to run snapper and aptitude in conjunction"
	echo "for installing/removing/updating packages using [snapper --command] to"
	echo "auto-create --pre and --post btrfs snapshots."
	echo ""
	echo "Available Commands:"
	echo " help"
	echo " version"
	echo " search"
	echo " list"
	echo " install"
	echo " purge"
	echo " remove"
	echo " upgrade"
	echo ""
}

# Help Message fn()
helpmsg() {
	echo "Snapt Command info:"
	echo " help:"
	echo "  Shows this help message"
	echo ""
	echo " version:"
	echo "  Shows the version"
	echo ""
	echo " search:"
	echo "  Searches [aptitude search] through repos to find packages"
	echo ""
	echo " list:"
	echo "  Lists [snapper list] all snapshots"
	echo ""
	echo " install:"
	echo "  Installs [aptitude install] new packages from repos"
	echo ""
	echo " purge:"
	echo "  Uninstalls [aptitude purge] new packages from repos"
	echo ""
	echo " remove:"
	echo "  Uninstalls [aptitude remove] new packages from repos"
	echo ""
	echo " upgrade:"
	echo "  Upgrade packages to their newest versions [aptitude safe-upgrade]"
	echo ""
}

## Script Start ##

# Force non-error fails to return as error
set -e

# Aptitude is required. If not installed, Abort
command -v aptitude >/dev/null 2>&1 || { echo >&2 "'aptitude' is required, please install it. Aborting."; exit 1; }
# Snapper is required. If not installed, Abort
command -v snapper >/dev/null 2>&1 || { echo >&2 "'snapper' is required, please install it. Aborting."; exit 1; }

# No Arguments
if [ "$#" -eq 0 ]; then
	echo "Error: Requires Arguments"
	echo ""
	helphead
	exit
fi

# Individual Commands
if [ $comm = "help" ]; then
	helphead
	helpmsg

	exit
elif [ $comm = "version" ]; then
	echo snapt $version

	exit
elif [ $comm = "search" ]; then
	# Check for root
	if [ "$EUID" -ne 0 ]; then
		shift
		aptitude search $*

		exit
	else
		shift
		aptitude update 	# Run aptitude update if root
		aptitude search $*

		exit
	fi

	exit
elif [ $comm = "list" ]; then
	# Check for root privileges
	if [ "$EUID" -ne 0 ]; then
		echo "This command needs root privileges."
		echo "Please re-run using root privileges"

		exit 1
	fi
	shift

	snapper list $*

	exit
elif [ $comm = "install" ]; then
	# Check for root privileges
	if [ "$EUID" -ne 0 ]; then
		echo "This command needs root privileges."
		echo "Please re-run using root privileges"

		exit 1
	fi

	shift

	aptcomm="aptitude install $*"
	aptitude update

	# Must have package names to install anything
	if [ "$#" -eq 0 ]; then
		echo "Requires package name to install"
		exit 1
	fi

	snapper -v create -d "snapt install" --command "$aptcomm"

	exit
elif [ $comm = "purge" ]; then
	# Check for root privileges
	if [ "$EUID" -ne 0 ]; then
		echo "This command needs root privileges."
		echo "Please re-run using root privileges"
<commit_msg>Fix: snapt list no longer passes args<commit_after>#!/usr/bin/env bash

## Variables ##

# Set first first arg[] as <command>
comm=$1

# Set Version Number
version="v0.4.2"

## Functions ##

# Help Header
helphead(){
	echo $version
	echo "Usage: snapt <command>"
	echo ""
	echo "Snapt is a script designed to run snapper and aptitude in conjunction"
	echo "for installing/removing/updating packages using [snapper --command] to"
	echo "auto-create --pre and --post btrfs snapshots."
	echo ""
	echo "Available Commands:"
	echo " help"
	echo " version"
	echo " search"
	echo " list"
	echo " install"
	echo " purge"
	echo " remove"
	echo " upgrade"
	echo ""
}

# Help Message fn()
helpmsg() {
	echo "Snapt Command info:"
	echo " help:"
	echo "  Shows this help message"
	echo ""
	echo " version:"
	echo "  Shows the version"
	echo ""
	echo " search:"
	echo "  Searches [aptitude search] through repos to find packages"
	echo ""
	echo " list:"
	echo "  Lists [snapper list] all snapshots"
	echo ""
	echo " install:"
	echo "  Installs [aptitude install] new packages from repos"
	echo ""
	echo " purge:"
	echo "  Uninstalls [aptitude purge] new packages from repos"
	echo ""
	echo " remove:"
	echo "  Uninstalls [aptitude remove] new packages from repos"
	echo ""
	echo " upgrade:"
	echo "  Upgrade packages to their newest versions [aptitude safe-upgrade]"
	echo ""
}

## Script Start ##

# Force non-error fails to return as error
set -e

# Aptitude is required. If not installed, Abort
command -v aptitude >/dev/null 2>&1 || { echo >&2 "'aptitude' is required, please install it. Aborting."; exit 1; }
# Snapper is required. If not installed, Abort
command -v snapper >/dev/null 2>&1 || { echo >&2 "'snapper' is required, please install it. Aborting."; exit 1; }

# No Arguments
if [ "$#" -eq 0 ]; then
	echo "Error: Requires Arguments"
	echo ""
	helphead
	exit
fi

# Individual Commands
if [ $comm = "help" ]; then
	helphead
	helpmsg

	exit
elif [ $comm = "version" ]; then
	echo snapt $version

	exit
elif [ $comm = "search" ]; then
	# Check for root
	if [ "$EUID" -ne 0 ]; then
		shift
		aptitude search $*

		exit
	else
		shift
		aptitude update 	# Run aptitude update if root
		aptitude search $*

		exit
	fi

	exit
elif [ $comm = "list" ]; then
	# Check for root privileges
	if [ "$EUID" -ne 0 ]; then
		echo "This command needs root privileges."
		echo "Please re-run using root privileges"

		exit 1
	fi
	shift

	snapper list

	exit
elif [ $comm = "install" ]; then
	# Check for root privileges
	if [ "$EUID" -ne 0 ]; then
		echo "This command needs root privileges."
		echo "Please re-run using root privileges"

		exit 1
	fi

	shift

	aptcomm="aptitude install $*"
	aptitude update

	# Must have package names to install anything
	if [ "$#" -eq 0 ]; then
		echo "Requires package name to install"
		exit 1
	fi

	snapper -v create -d "snapt install" --command "$aptcomm"

	exit
elif [ $comm = "purge" ]; then
	# Check for root privileges
	if [ "$EUID" -ne 0 ]; then
		echo "This command needs root privileges."
		echo "Please re-run using root privileges"

{'fraction_non_alphanumeric': 0.1167895167895168, 'fraction_numerical': 0.0068796068796068794, 'mean_word_length': 3.3991354466858787, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2286764', 'n_tokens_mistral': 2163, 'n_tokens_neox': 2020, 'n_words': 806}