Better rewrite in rust #6
5 changed files with 240 additions and 218 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
target/
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parch-tweaks"
|
||||||
|
version = "0.1.0"
|
2
ptt
2
ptt
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
python /usr/share/parchlinux/parchtweaks/ptt.py
|
/usr/share/parchlinux/parchtweaks/ptt
|
||||||
|
|
101
ptt.py
101
ptt.py
|
@ -1,101 +0,0 @@
|
||||||
import os
|
|
||||||
|
|
||||||
while True:
|
|
||||||
os.system("figlet 'Parch Linux tweak tool'")
|
|
||||||
print("Please select a section:")
|
|
||||||
print("1) Change Emoji package")
|
|
||||||
print("2) Libreoffice Installer")
|
|
||||||
print("3) Change Aur Helper")
|
|
||||||
print("4) Install Editor configs")
|
|
||||||
print("5) Exit")
|
|
||||||
|
|
||||||
choice = input("Enter your choice: ")
|
|
||||||
|
|
||||||
if choice == "1":
|
|
||||||
print("Please choose an action for emoji Packages:")
|
|
||||||
print("1) ios")
|
|
||||||
print("2) fluent (microsoft)")
|
|
||||||
emoji_choice = input("Enter your choice: ")
|
|
||||||
|
|
||||||
if emoji_choice == "1":
|
|
||||||
os.system("sudo pacman -Rds fluent-emojies --noconfirm")
|
|
||||||
os.system("sudo pacman -Sy parch-emoji-ios --noconfirm")
|
|
||||||
elif emoji_choice == "2":
|
|
||||||
os.system("sudo pacman -Rds parch-emoji-ios --noconfirm")
|
|
||||||
os.system("sudo pacman -Sy fluent-emojies --noconfirm")
|
|
||||||
else:
|
|
||||||
print("Invalid choice.")
|
|
||||||
elif choice == "2":
|
|
||||||
os.system("sudo pacman -Sy libreoffice-fresh --noconfirm")
|
|
||||||
os.system("rm -rf ~/.config/libreoffice")
|
|
||||||
os.system("git clone https://github.com/parchlinux/libreoffice-config /tmp/libreoffice")
|
|
||||||
os.system("cp -r /tmp/libreoffice/libreoffice ~/.config")
|
|
||||||
elif choice == "3":
|
|
||||||
print("Please choose an action for aur helper:")
|
|
||||||
print("1) yay")
|
|
||||||
print("2) paru (default in parchlinux)")
|
|
||||||
aur = input("Enter your choice: ")
|
|
||||||
|
|
||||||
if aur == "1":
|
|
||||||
os.system("sudo pacman -Rds paru --noconfirm")
|
|
||||||
os.system("sudo pacman -Sy yay --noconfirm")
|
|
||||||
elif aur == "2":
|
|
||||||
os.system("sudo pacman -Rds yay --noconfirm")
|
|
||||||
os.system("sudo pacman -Sy paru --noconfirm")
|
|
||||||
else:
|
|
||||||
print("Invalid choice.")
|
|
||||||
elif choice == "4":
|
|
||||||
print("Please choose an action for your editor configs:")
|
|
||||||
print("1) neovim")
|
|
||||||
print("2) emacs")
|
|
||||||
print("3) vim")
|
|
||||||
ediconf = input("Enter your choice: ")
|
|
||||||
|
|
||||||
if ediconf == "1":
|
|
||||||
print("Please choose an action for your neovim config:")
|
|
||||||
print("1) nvchad")
|
|
||||||
print("2) nvpak")
|
|
||||||
print("3) lunarvim")
|
|
||||||
neoconf = input("Enter your choice: ")
|
|
||||||
|
|
||||||
if neoconf == "1":
|
|
||||||
os.system("sudo pacman -S neovim git --noconfirm")
|
|
||||||
os.system("git clone https://github.com/NvChad/NvChad ~/.config/nvim --depth 1")
|
|
||||||
print("now you can run neovim by typing: nvim")
|
|
||||||
elif neoconf == "2":
|
|
||||||
os.system("sudo pacman -S neovim git --noconfirm")
|
|
||||||
os.system("git clone --depth 1 https://github.com/Pakrohk-DotFiles/NvPak.git ~/.config/nvim")
|
|
||||||
print("now you can run neovim by typing: nvim")
|
|
||||||
elif neoconf == "3":
|
|
||||||
os.system("sudo pacman -S neovim git --noconfirm")
|
|
||||||
os.system("LV_BRANCH='release-1.3/neovim-0.9' bash <(curl -s https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh)")
|
|
||||||
else:
|
|
||||||
print("Invalid choice.")
|
|
||||||
elif ediconf == "2":
|
|
||||||
print("Please choose an action for your editor configs:")
|
|
||||||
print("1) Doom emacs")
|
|
||||||
print("2) Spacemacs")
|
|
||||||
emacconf = input("Enter your choice: ")
|
|
||||||
|
|
||||||
if emacconf == "1":
|
|
||||||
os.system("sudo pacman -S emacs git --noconfirm")
|
|
||||||
os.system("git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.config/emacs")
|
|
||||||
print("dont forgot to add ~/.config/emacs/bin to your path.")
|
|
||||||
print("after adding to path, re run your terminal and type doom install.")
|
|
||||||
elif emacconf == "2":
|
|
||||||
os.system("sudo pacman -S emacs git --noconfirm")
|
|
||||||
os.system("git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d")
|
|
||||||
print("now you can now open emacs for changes to take effect.")
|
|
||||||
else:
|
|
||||||
print("Invalid choice.")
|
|
||||||
elif ediconf == "3":
|
|
||||||
print("soon.....")
|
|
||||||
else:
|
|
||||||
print("Invalid choice.")
|
|
||||||
elif choice == "5":
|
|
||||||
exit(0)
|
|
||||||
else:
|
|
||||||
print("Invalid choice.")
|
|
||||||
|
|
||||||
print(f"Done with section {choice}.")
|
|
||||||
|
|
347
src/main.rs
347
src/main.rs
|
@ -1,124 +1,239 @@
|
||||||
use std::{process::{Command, self}, io};
|
use std::{
|
||||||
fn execute_command(command:&str , args:Vec<&str>){
|
io,
|
||||||
Command::new(command)
|
io::Write,
|
||||||
.args(args)
|
process::{self, Command},
|
||||||
.output()
|
};
|
||||||
.expect("failed to execute the process");
|
|
||||||
|
const INVALID_CHOICE: &str = "Invalid choice.";
|
||||||
|
const PLEASE_CHOOSE: &str = "Please choose an action for";
|
||||||
|
|
||||||
|
fn execute_command(command: &str, args: Vec<&str>) {
|
||||||
|
let output = Command::new(command)
|
||||||
|
.args(args)
|
||||||
|
.output()
|
||||||
|
.expect("failed to execute the process");
|
||||||
|
|
||||||
|
if output.status.success() {
|
||||||
|
io::stdout().write_all(&output.stdout).unwrap();
|
||||||
|
} else {
|
||||||
|
io::stdout().write_all(&output.stderr).unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn get_inputed(print:&str)->String{
|
|
||||||
println!("{}",print);
|
fn get_choice() -> String {
|
||||||
|
println!("Enter your choice: ");
|
||||||
|
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
io::stdin().read_line(&mut input).unwrap_or_else(|_|{process::exit(1)});
|
io::stdin()
|
||||||
return input.to_owned()
|
.read_line(&mut input)
|
||||||
|
.unwrap_or_else(|_| process::exit(1));
|
||||||
|
|
||||||
|
input.trim().to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn install_emoji_packages() {
|
||||||
|
println!("{PLEASE_CHOOSE} emoji Packages:\n\
|
||||||
|
1) ios\n\
|
||||||
|
2) fluent (microsoft)");
|
||||||
|
|
||||||
|
let emoji_choice = get_choice();
|
||||||
|
match emoji_choice.as_str() {
|
||||||
|
"1" => {
|
||||||
|
execute_command(
|
||||||
|
"sudo",
|
||||||
|
vec!["pacman", "-Rds", "fluent-emojies", "--noconfirm"],
|
||||||
|
);
|
||||||
|
execute_command(
|
||||||
|
"sudo",
|
||||||
|
vec!["pacman", "-Sy", "parch-emoji-ios", "--noconfirm"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
"2" => {
|
||||||
|
execute_command(
|
||||||
|
"sudo",
|
||||||
|
vec!["pacman", "-Rds", "parch-emoji-ios", "--noconfirm"],
|
||||||
|
);
|
||||||
|
execute_command(
|
||||||
|
"sudo",
|
||||||
|
vec!["pacman", "-Sy", "fluent-emojies", "--noconfirm"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => println!("{INVALID_CHOICE}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn install_libreoffice() {
|
||||||
|
execute_command(
|
||||||
|
"sudo",
|
||||||
|
vec!["pacman", "-Sy", "libreoffice-fresh", "--noconfirm"],
|
||||||
|
);
|
||||||
|
execute_command("rm", vec!["-rf", "~/.config/liberoffice"]);
|
||||||
|
execute_command(
|
||||||
|
"git",
|
||||||
|
vec![
|
||||||
|
"clone",
|
||||||
|
"https://github.com/parchlinux/libreoffice-config",
|
||||||
|
"/tmp/liberoffice",
|
||||||
|
],
|
||||||
|
);
|
||||||
|
execute_command(
|
||||||
|
"cp",
|
||||||
|
vec!["-r", "/tmp/liberoffice/liberoffice", "~/.config"],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn change_aur_helper() {
|
||||||
|
println!("{PLEASE_CHOOSE} aur helper:\n\
|
||||||
|
1) yay\n\
|
||||||
|
2) paru (default in parchlinux");
|
||||||
|
|
||||||
|
let aur = get_choice();
|
||||||
|
match aur.as_str() {
|
||||||
|
"1" => {
|
||||||
|
execute_command("sudo", vec!["pacman", "-Rds", "paru", "--noconfirm"]);
|
||||||
|
execute_command("sudo", vec!["pacman", "-Sy", "yay", "--noconfirm"]);
|
||||||
|
}
|
||||||
|
"2" => {
|
||||||
|
execute_command("sudo", vec!["pacman", "-Rds", "yay", "--noconfirm"]);
|
||||||
|
execute_command("sudo", vec!["pacman", "-Sy", "paru", "--noconfirm"]);
|
||||||
|
}
|
||||||
|
_ => println!("{INVALID_CHOICE}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod install_neovim_config {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub fn nvchad() {
|
||||||
|
execute_command("sudo", vec!["pacman", "-S", "neovim", "git", "--noconfirm"]);
|
||||||
|
execute_command(
|
||||||
|
"git",
|
||||||
|
vec![
|
||||||
|
"clone",
|
||||||
|
"https://github.com/NvChad/NvChad",
|
||||||
|
"~/.config/nvim",
|
||||||
|
"--depth",
|
||||||
|
"1",
|
||||||
|
],
|
||||||
|
);
|
||||||
|
println!("now you can run neovim by typing: nvim")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn nvpack() {
|
||||||
|
execute_command("sudo", vec!["pacman", "-S", "neovim", "git", "--noconfirm"]);
|
||||||
|
execute_command(
|
||||||
|
"git",
|
||||||
|
vec![
|
||||||
|
"clone",
|
||||||
|
"--depth",
|
||||||
|
"1",
|
||||||
|
"https://github.com/Pakrohk-DotFiles/NvPak.git",
|
||||||
|
" ~/.config/nvim",
|
||||||
|
],
|
||||||
|
);
|
||||||
|
println!("now you can run neovim by typing: nvim");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn lunarvim() {
|
||||||
|
execute_command("sudo", vec!["pacman", "-S", "neovim", "git", "--noconfirm"]);
|
||||||
|
execute_command(
|
||||||
|
"LV_BRANCH='release-1.3/neovim-0.9'",
|
||||||
|
vec!["bash", "<(curl", "-s",
|
||||||
|
"https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh)"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod install_emacs_config {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub fn doomemacs() {
|
||||||
|
execute_command("sudo", vec!["pacman", "-S", "emacs", "git", "--noconfirm"]);
|
||||||
|
execute_command(
|
||||||
|
"git",
|
||||||
|
vec![
|
||||||
|
"clone",
|
||||||
|
"--depth",
|
||||||
|
"1",
|
||||||
|
"https://github.com/doomemacs/doomemacs",
|
||||||
|
"~/.config/emacs",
|
||||||
|
],
|
||||||
|
);
|
||||||
|
println!("dont forgot to add ~/.config/emacs/bin to your path.");
|
||||||
|
println!("after adding to path, re run your terminal and type doom install.");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn spacemacs() {
|
||||||
|
execute_command("sudo", vec!["pacman", "-S", "emacs", "git", "--noconfirm"]);
|
||||||
|
execute_command(
|
||||||
|
"git",
|
||||||
|
vec![
|
||||||
|
"clone",
|
||||||
|
"https://github.com/syl20bnr/spacemacs",
|
||||||
|
"~/.emacs.d",
|
||||||
|
],
|
||||||
|
);
|
||||||
|
println!("now you can now open emacs for changes to take effect.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn install_editor_configs() {
|
||||||
|
println!("{PLEASE_CHOOSE} your editor configs:\n\
|
||||||
|
1) neovim\n\
|
||||||
|
2) emacs\n\
|
||||||
|
3) vim");
|
||||||
|
|
||||||
|
let ediconf = get_choice();
|
||||||
|
match ediconf.as_str() {
|
||||||
|
"1" => {
|
||||||
|
println!("{PLEASE_CHOOSE} your neovim config:\n\
|
||||||
|
1) nvchad\n\
|
||||||
|
2) nvpak\n\
|
||||||
|
3) lunarvim");
|
||||||
|
|
||||||
|
let neoconf = get_choice();
|
||||||
|
match neoconf.as_str() {
|
||||||
|
"1" => install_neovim_config::nvchad(),
|
||||||
|
"2" => install_neovim_config::nvpack(),
|
||||||
|
"3" => install_neovim_config::lunarvim(),
|
||||||
|
_ => println!("{INVALID_CHOICE}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"2" => {
|
||||||
|
println!("{PLEASE_CHOOSE} your editor configs:\n\
|
||||||
|
1) DoomEmacs\n\
|
||||||
|
2) Spacemacs");
|
||||||
|
|
||||||
|
let emacconf = get_choice();
|
||||||
|
match emacconf.as_str() {
|
||||||
|
"1" => install_emacs_config::doomemacs(),
|
||||||
|
"2" => install_emacs_config::spacemacs(),
|
||||||
|
_ => println!("{INVALID_CHOICE}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"3" => println!("Soon..."),
|
||||||
|
_ => println!("{INVALID_CHOICE}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
execute_command("figlet", vec!["Parch Linux tweak tool"]);
|
execute_command("figlet", vec!["Parch Linux tweak tool"]);
|
||||||
|
|
||||||
println!("Please select a section:");
|
println!("Please select a section:\n\
|
||||||
println!("1) Change Emoji package");
|
1) Change Emoji package\n\
|
||||||
println!("2) Libreoffice Installer");
|
2) Install Libreoffice\n\
|
||||||
println!("3) Change Aur Helper");
|
3) Change Aur Helper\n\
|
||||||
println!("4) Install Editor configs");
|
4) Install Editor configs\n\
|
||||||
println!("5) Exit");
|
5) Exit");
|
||||||
let choice = get_inputed("Enter your choice: ");
|
|
||||||
match choice.as_str(){
|
let choice = get_choice();
|
||||||
"1"=>{
|
match choice.as_str() {
|
||||||
println!("Please choose an action for emoji Packages:");
|
"1" => install_emoji_packages(),
|
||||||
println!("1) ios");
|
"2" => install_libreoffice(),
|
||||||
println!("2) fluent (microsoft)");
|
"3" => change_aur_helper(),
|
||||||
let emoji_choice = get_inputed("Enter your choice:");
|
"4" => install_editor_configs(),
|
||||||
match emoji_choice.as_str() {
|
"5" => process::exit(0),
|
||||||
"1"=>{execute_command("sudo", vec!["pacman","-Rds","fluent-emojies","--noconfirm"]);
|
_ => println!("{INVALID_CHOICE}"),
|
||||||
execute_command("sudo", vec!["pacman","-Sy","parch-emoji-ios","--noconfirm"]);
|
|
||||||
}
|
|
||||||
"2"=>{execute_command("sudo", vec!["pacman","-Rds","parch-emoji-ios","--noconfirm"]);
|
|
||||||
execute_command("sudo", vec!["pacman","-Sy","fluent-emojies","--noconfirm"]);
|
|
||||||
}
|
|
||||||
&_=>println!("Invalid choice.")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"2"=>{
|
|
||||||
execute_command("sudo", vec!["pacman","-Sy","libreoffice-fresh","--noconfirm"]);
|
|
||||||
execute_command("rm", vec!["-rf","~/.config/liberoffice"]);
|
|
||||||
execute_command("git", vec!["clone","https://github.com/parchlinux/libreoffice-config","/tmp/liberoffice"]);
|
|
||||||
execute_command("cp", vec!["-r","/tmp/liberoffice/liberoffice","~/.config"])
|
|
||||||
}
|
|
||||||
"3"=>{
|
|
||||||
println!("Please choose an action for aur helper:");
|
|
||||||
println!("1) yay");
|
|
||||||
println!("2) paru (default in parchlinux)");
|
|
||||||
let aur = get_inputed("Enter your choice:");
|
|
||||||
match aur.as_str() {
|
|
||||||
"1"=>{
|
|
||||||
execute_command("sudo", vec!["pacman","-Rds","paru","--noconfirm"]);
|
|
||||||
execute_command("sudo", vec!["pacman","-Sy","yay","--noconfirm"]);
|
|
||||||
},
|
|
||||||
"2"=>{
|
|
||||||
execute_command("sudo", vec!["pacman","-Rds","yay","--noconfirm"]);
|
|
||||||
execute_command("sudo", vec!["pacman","-Sy","paru","--noconfirm"]);
|
|
||||||
}
|
|
||||||
&_=>println!("Invalid choice.")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"4"=>{
|
|
||||||
println!("Please choose an action for your editor configs:");
|
|
||||||
println!("1) neovim");
|
|
||||||
println!("2) emacs");
|
|
||||||
println!("3) vim");
|
|
||||||
let ediconf = get_inputed("Enter your choice: ");
|
|
||||||
match ediconf.as_str(){
|
|
||||||
"1"=>{
|
|
||||||
println!("Please choose an action for your neovim config:");
|
|
||||||
println!("1) nvchad");
|
|
||||||
println!("2) nvpak");
|
|
||||||
println!("3) lunarvim");
|
|
||||||
let neoconf = get_inputed("Enter your choice:");
|
|
||||||
match neoconf.as_str(){
|
|
||||||
"1"=>{
|
|
||||||
execute_command("sudo", vec!["pacman","-S","neovim","git","--noconfirm"]);
|
|
||||||
execute_command("git", vec!["clone","https://github.com/NvChad/NvChad","~/.config/nvim","--depth","1"]);
|
|
||||||
println!("now you can run neovim by typing: nvim")
|
|
||||||
}
|
|
||||||
"2"=>{
|
|
||||||
execute_command("sudo", vec!["pacman","-S","neovim","git","--noconfirm"]);
|
|
||||||
execute_command("git", vec!["clone", "--depth", "1", "https://github.com/Pakrohk-DotFiles/NvPak.git"," ~/.config/nvim"]);
|
|
||||||
println!("now you can run neovim by typing: nvim");
|
|
||||||
}
|
|
||||||
"3"=>{
|
|
||||||
execute_command("sudo", vec!["pacman","-S","neovim","git","--noconfirm"]);
|
|
||||||
execute_command("LV_BRANCH='release-1.3/neovim-0.9'", vec!["bash","<(curl","-s","https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh)"]);
|
|
||||||
}
|
|
||||||
&_=>println!("Invalid choice.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"2"=>{
|
|
||||||
println!("Please choose an action for your editor configs:");
|
|
||||||
println!("1) Dooedm emacs");
|
|
||||||
println!("2) Spaedcemacs");
|
|
||||||
let emacconf = get_inputed("Enter your choice: ");
|
|
||||||
match emacconf.as_str(){
|
|
||||||
"1"=>{
|
|
||||||
execute_command("sudo",vec!["pacman","-S","emacs","git","--noconfirm"]);
|
|
||||||
execute_command("git",vec!["clone","--depth","1","https://github.com/doomemacs/doomemacs","~/.config/emacs"]);
|
|
||||||
println!("dont forgot to add ~/.config/emacs/bin to your path.");
|
|
||||||
println!("after adding to path, re run your terminal and type doom install.");
|
|
||||||
},
|
|
||||||
"2"=>{
|
|
||||||
execute_command("sudo",vec!["pacman","-S","emacs","git","--noconfirm"]);
|
|
||||||
execute_command("git",vec!["clone","https://github.com/syl20bnr/spacemacs","~/.emacs.d"]);
|
|
||||||
println!("now you can now open emacs for changes to take effect.");
|
|
||||||
}
|
|
||||||
"3"=>{
|
|
||||||
println!("soon...");
|
|
||||||
}
|
|
||||||
&_=>println!("Invalid choice.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&_=>println!("Invalid choice.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"5"=>process::exit(0),
|
|
||||||
&_=>{println!("invalid choice")}
|
|
||||||
}
|
}
|
||||||
println!("done with section {}.",choice);
|
println!("done with section {}.", choice);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue