Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Expelliarmus spell #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions cmd/wand/expelliarmus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package wand

import (
"fmt"

"github.com/FOSS-Community/wand/pkg/wand"
"github.com/spf13/cobra"
)

var expelliarmusLogo string = fmt.Sprintf(`%s
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣠⠖⠉⠁⠀⠀⠀⠈⠉⠲⢤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣀⡴⠡⠤⠤⣝⡒⠒⣚⡥⠤⠤⠀⠹⠤⠤⠤⢤⣀⡀⠀⠀⠀⠀
⠀⡠⢚⣩⠤⡄⠀⣠⢺⣓⢦⠈⠉⠀⡴⣺⡒⣄⠀⠀⡔⠋⠑⠲⢭⡲⣄⠀⠀
⡼⢱⠋⠀⠀⠱⠂⢣⡻⠼⡸⠀⠀⠀⢇⠧⢝⡼⠀⢠⠃⠀⠀⢀⡤⠥⢬⣣⡀
⠉⠙⠒⠲⢤⡀⠀⠀⢉⣍⡤⠄⠀⢀⣌⣉⠉⠀⠀⠞⠀⠀⣠⠎⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠑⠤⡄⠛⠈⢳⡀⠀⡴⠚⠈⠙⡆⢠⠤⠴⠊⠁⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠘⣄⢀⠀⠧⠜⠀⠀⠀⠈⣡⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠘⢦⡑⠦⠤⠤⠒⢁⠜⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠒⠒⠒⠚⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
%s`, Cyan, Reset)

var expelliarmusDescription string = fmt.Sprintf(`%s
%sThe Expelliarmus spell disarms an opponent, making them drop whatever they are holding.%s

%sIn the "wand" library, this command will correspond to killing a process in Linux. :)%s

Usage : %s$ wand expelliarmus <process_id>%s

%sCheers!%s
`, Cyan, Magenta, Reset, Yellow, Reset, Green, Reset, Red, Reset)

var expelliarmusCmd = &cobra.Command{
Use: "expelliarmus",
Long: fmt.Sprintf("%s %s", expelliarmusLogo, expelliarmusDescription),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
arg := args[0]

// List of critical processes that should not be killed
criticalProcesses := []string{
"init",
"systemd",
"cron",
"sshd",
}
for _, criticalProcess := range criticalProcesses {
if arg == criticalProcess {
fmt.Printf("Error: Attempting to kill critical system process: %s\n", criticalProcess)
return
}
}
wand.Runcommand("kill", arg)
},
}

func init() {
rootCmd.AddCommand(expelliarmusCmd)
}
3 changes: 2 additions & 1 deletion cmd/wand/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ var commandlist = []string{
fmt.Sprintf("\t%s6.\tavada-kedavra%s\n", Cyan, Reset),
fmt.Sprintf("\t%s7.\taccio%s\n", Red, Reset),
fmt.Sprintf("\t%s8.\tnox%s\n", White, Reset),
fmt.Sprintf("\t%s9.\reducio%s\n", Red, Reset),
fmt.Sprintf("\t%s9.\treducio%s\n", Red, Reset),
fmt.Sprintf("\t%s10.\texpelliarmus%s\n", Red, Reset),
}

var logowand string = `
Expand Down