started work on install windows
This commit is contained in:
parent
222e4c43da
commit
ca543c10b7
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
flist
|
flist
|
||||||
flist.exe
|
flist.exe
|
||||||
|
test/
|
60
flist.v
60
flist.v
@ -23,6 +23,60 @@ struct Response {
|
|||||||
payload Payload
|
payload Payload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_path_windows() {
|
||||||
|
// Define the new directory path to add
|
||||||
|
new_path := r'C:\Program Files\flist'
|
||||||
|
|
||||||
|
// Get the current PATH environment variable
|
||||||
|
current_path := os.getenv('PATH')
|
||||||
|
|
||||||
|
// Check if the new_path is already in the current PATH
|
||||||
|
if current_path.contains(new_path) {
|
||||||
|
println('The directory is already in the PATH.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct the new PATH by appending the new_path
|
||||||
|
new_env_path := '${current_path};${new_path}'
|
||||||
|
|
||||||
|
// Prepare the command to set the new PATH
|
||||||
|
cmd := 'setx PATH "${new_env_path}"'
|
||||||
|
|
||||||
|
// Execute the command to update the PATH
|
||||||
|
exit_code := os.system(cmd.replace('"$', '${new_env_path}"'))
|
||||||
|
|
||||||
|
if exit_code == 0 {
|
||||||
|
println('PATH updated successfully.')
|
||||||
|
} else {
|
||||||
|
println('Failed to update the PATH. Please try running the script as an administrator.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_path_windows() {
|
||||||
|
// Define the directory path to remove
|
||||||
|
path_to_remove := r'C:\Program Files\flist'
|
||||||
|
|
||||||
|
// Get the current PATH environment variable
|
||||||
|
mut current_path := os.getenv('PATH')
|
||||||
|
|
||||||
|
// Remove the specified path from current PATH
|
||||||
|
paths := current_path.split(';')
|
||||||
|
updated_paths := paths.filter(it != path_to_remove) // Keep only paths that are not the one we want to remove
|
||||||
|
new_env_path := updated_paths.join(';') // Join the remaining paths back into a single string
|
||||||
|
|
||||||
|
// Prepare the command to set the new PATH
|
||||||
|
cmd := 'setx PATH "${new_env_path}"'
|
||||||
|
|
||||||
|
// Execute the command to update the PATH
|
||||||
|
exit_code := os.system(cmd.replace('"$', '${new_env_path}"'))
|
||||||
|
|
||||||
|
if exit_code == 0 {
|
||||||
|
println('PATH updated successfully.')
|
||||||
|
} else {
|
||||||
|
println('Failed to update the PATH. Please try running the script as an administrator.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn error_message(msg string) {
|
fn error_message(msg string) {
|
||||||
println(term.red('\nError: ') + msg)
|
println(term.red('\nError: ') + msg)
|
||||||
println(term.yellow("Run 'flist help' for usage information.\n"))
|
println(term.yellow("Run 'flist help' for usage information.\n"))
|
||||||
@ -68,6 +122,9 @@ fn install() {
|
|||||||
os.mkdir_all(os.dir(binary_location)) or { panic(err) }
|
os.mkdir_all(os.dir(binary_location)) or { panic(err) }
|
||||||
os.cp(current_exe, binary_location) or { panic(err) }
|
os.cp(current_exe, binary_location) or { panic(err) }
|
||||||
os.chmod(binary_location, 0o755) or { panic(err) }
|
os.chmod(binary_location, 0o755) or { panic(err) }
|
||||||
|
if os.user_os() == 'windows' {
|
||||||
|
add_path_windows()
|
||||||
|
}
|
||||||
success_message('Flist CLI has been installed to ' + binary_location)
|
success_message('Flist CLI has been installed to ' + binary_location)
|
||||||
info_message("You can now use it by running 'flist help'")
|
info_message("You can now use it by running 'flist help'")
|
||||||
} else {
|
} else {
|
||||||
@ -84,6 +141,9 @@ fn uninstall() {
|
|||||||
} else {
|
} else {
|
||||||
info_message('Flist CLI is not installed at ' + binary_location)
|
info_message('Flist CLI is not installed at ' + binary_location)
|
||||||
}
|
}
|
||||||
|
// if os.user_os() == 'windows' {
|
||||||
|
// remove_path_windows()
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn login() {
|
fn login() {
|
||||||
|
Loading…
Reference in New Issue
Block a user