@@ -29,6 +29,27 @@ function check_requirements() {
2929 check_command " uv" " uv is optional but recommended for better performance, install it with 'pip install uv'. Their script is useful"
3030}
3131
32+ export INSTALL_IDENTIFIER=" WeaponizedVSCode installation script. The following commands are generated by WeaponizedVSCode installer."
33+
34+ function args() {
35+ while [[ " $# " -gt 0 ]]; do
36+ case " $1 " in
37+ (--trace-mode)
38+ export WEAPON_TRACE_MODE=true
39+ shift
40+ ;;
41+ (--force-install)
42+ export WEAPON_FORCE_INSTALL=true
43+ shift
44+ ;;
45+ * )
46+ echo " Unknown option: $1 "
47+ exit 1
48+ ;;
49+ esac
50+ done
51+ }
52+
3253function main() {
3354 check_requirements
3455 if [[ $? -ne 0 && " $FORCE_INSTALL " != " true" ]]; then
@@ -45,8 +66,16 @@ function main() {
4566
4667 if [[ -d " $WEAPON_LOCATION " ]]; then
4768 echo " Weapon already installed."
69+ if [[ " $WEAPON_FORCE_INSTALL " == " true" ]]; then
70+ echo " Force install mode enabled, removing existing Weapon directory at $WEAPON_LOCATION ."
71+ rm -rf " $WEAPON_LOCATION "
72+ else
73+ echo " If you want to reinstall Weapon, please remove the existing directory at $WEAPON_LOCATION or use --force-install option."
74+ exit 0
75+ fi
4876 exit 0
4977 fi
78+
5079 export LOCATION=" $WEAPON_LOCATION "
5180 echo " Weapon will be installed to $LOCATION , Press Enter key to continue or Ctrl+C to cancel..."
5281 read
@@ -55,15 +84,37 @@ function main() {
5584 cat ./createhackenv.sh | sed -e " s#__REPLACE__#$LOCATION #g" > $LOCATION /createhackenv.sh && echo " createhackenv.sh copied to $LOCATION ."
5685 cp -f ./zsh_history $LOCATION && echo " zsh_history copied to $LOCATION ."
5786
58- grep -zq " source $LOCATION /createhackenv.sh" ~ /.zshrc
87+ if [[ " $WEAPON_TRACE_MODE " == " true" ]]; then
88+ cp -f ./zsh_preformance_tracer.sh $LOCATION && echo " zsh_performance_tracer is copied to $LOCATION ."
89+ fi
90+
91+ grep -zq " ${INSTALL_IDENTIFIER} " ~ /.zshrc
5992 if [[ $? -eq 0 ]]; then
6093 echo " createhackenv.sh already sourced in ~/.zshrc. sktpping..."
6194 else
6295 echo " Sourcing createhackenv.sh in ~/.zshrc..."
63- echo " source $LOCATION /createhackenv.sh" >> ~/.zshrc
96+ cp ~ /.zshrc ~ /.zshrc.pre-weaponized-vscode && echo " Backup ~/.zshrc to ~/.zshrc.pre-weaponized-vscode"
97+
98+ if [[ " $WEAPON_TRACE_MODE " == " true" ]]; then
99+ cat<< EOF >> ~/.zshrc
100+
101+ # ${INSTALL_IDENTIFIER}
102+ [[ -f $LOCATION /zsh_preformance_tracer.sh ]] && source $LOCATION /zsh_preformance_tracer.sh && zsh_trace_start
103+ [[ -f $LOCATION /createhackenv.sh ]] && source $LOCATION /createhackenv.sh
104+ [[ -f $LOCATION /zsh_performance_tracer ]] && zsh_trace_end
105+ EOF
106+ else
107+ cat<< EOF >> ~/.zshrc
108+
109+ # ${INSTALL_IDENTIFIER}
110+ [[ -f $LOCATION /createhackenv.sh ]] && source $LOCATION /createhackenv.sh
111+ EOF
112+ fi
113+
64114 fi
65115
66116 echo " Weaponized VSCode installation completed."
67117}
68118
69- main " $@ "
119+ args " $@ "
120+ main
0 commit comments