fixed mac specific error

This commit is contained in:
mik-tf 2024-10-10 09:57:15 -04:00
parent a39c062339
commit 6d0781cdc4

23
flist.v
View File

@ -5,23 +5,27 @@ import json
import x.json2 import x.json2
const token_file = os.join_path(os.home_dir(), '.config', 'tfhubtoken') const token_file = os.join_path(os.home_dir(), '.config', 'tfhubtoken')
const token_dir = os.join_path(os.home_dir(), '.config') const token_dir = os.join_path(os.home_dir(), '.config')
const binary_location = $if windows { const binary_location = $if windows {
'C:\\Program Files\\flist\\flist.exe' 'C:\\Program Files\\flist\\flist.exe'
} $else { } $else {
'/usr/local/bin/flist' '/usr/local/bin/flist'
} }
const docker_cmd = $if windows { const docker_cmd = $if windows {
'docker' 'docker'
} $else { } $else {
'sudo docker' 'sudo docker'
} }
const info_msg = $if windows { const info_msg = $if windows {
'Note: Make sure to use an admin PowerShell. Docker Desktop must be running to use the push function.\n' 'Note: Make sure to use an admin PowerShell. Docker Desktop must be running to use the push function.\n'
} $else $if linux { } $else $if linux {
'Note: Docker Engine must be running to use the push function.\n' 'Note: Docker Engine must be running to use the push function.\n'
} $else $if macos { } $else $if macos {
'Note: Docker desktop must be running to use the push function.\n' 'Note: Docker Desktop must be running to use the push function.\n'
} }
struct FlistItem { struct FlistItem {
@ -157,18 +161,6 @@ fn uninstall() {
// Remove the binary file // Remove the binary file
os.rm(binary_location) or { panic(err) } os.rm(binary_location) or { panic(err) }
success_message('Flist CLI has been removed from ' + binary_location) success_message('Flist CLI has been removed from ' + binary_location)
// Get the directory of the binary
parent_dir := os.dir(binary_location)
// Check if the parent directory is empty
if os.is_dir_empty(parent_dir) {
// Remove the parent directory
os.rmdir(parent_dir) or { panic(err) }
success_message('The directory ' + parent_dir + ' has been removed as it is empty.')
} else {
info_message('The directory ' + parent_dir + ' is not empty, so it was not removed.')
}
} else { } else {
info_message('Flist CLI is not installed at ' + binary_location) info_message('Flist CLI is not installed at ' + binary_location)
} }
@ -521,9 +513,12 @@ fn help() {
println(term.cyan(' ls url ') + '- List all Flists of the current user with full URLs') println(term.cyan(' ls url ') + '- List all Flists of the current user with full URLs')
println(term.cyan(' help ') + '- Display this help message\n') println(term.cyan(' help ') + '- Display this help message\n')
println(term.bold('Usage:')) println(term.bold('Usage:'))
$if !windows { $if linux {
println(term.yellow(' sudo ./flist install')) println(term.yellow(' sudo ./flist install'))
println(term.yellow(' sudo flist uninstall')) println(term.yellow(' sudo flist uninstall'))
} $else $if macos {
println(term.yellow(' sudo ./flist install'))
println(term.yellow(' flist uninstall'))
} }
println(term.yellow(' flist login')) println(term.yellow(' flist login'))
println(term.yellow(' flist logout')) println(term.yellow(' flist logout'))