You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.0 KiB
95 lines
2.0 KiB
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"marmic/servicetrade-toolbox/internal/api"
|
|
"marmic/servicetrade-toolbox/internal/handlers/cli"
|
|
"marmic/servicetrade-toolbox/internal/ui"
|
|
"marmic/servicetrade-toolbox/internal/utils"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
ui.DisplayStartScreen()
|
|
|
|
email, password, err := utils.PromptCredentials()
|
|
if err != nil {
|
|
ui.DisplayError("Error getting credentials:", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
session := api.NewSession()
|
|
err = session.Login(email, password)
|
|
if err != nil {
|
|
ui.DisplayError("Authentication failed:", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
fmt.Println("Login successful!")
|
|
|
|
for {
|
|
ui.ClearScreen()
|
|
fmt.Println("Main Menu:")
|
|
fmt.Println("1. Jobs")
|
|
fmt.Println("2. Invoices")
|
|
fmt.Println("3. Companies")
|
|
fmt.Println("4. Assets")
|
|
fmt.Println("5. Contacts")
|
|
fmt.Println("6. Contracts")
|
|
fmt.Println("7. Generic Tools")
|
|
fmt.Println("8. Locations")
|
|
fmt.Println("9. Notifications")
|
|
fmt.Println("10. Quotes")
|
|
fmt.Println("11. Services")
|
|
fmt.Println("12. Tags")
|
|
fmt.Println("13. Users")
|
|
fmt.Println("14. Admin")
|
|
fmt.Println("15. Logout")
|
|
|
|
choice, err := utils.GetUserChoice(15)
|
|
if err != nil {
|
|
ui.DisplayError("Invalid input:", err)
|
|
utils.PressEnterToContinue()
|
|
continue
|
|
}
|
|
switch choice {
|
|
case 1:
|
|
cli.HandleJobs(session)
|
|
case 2:
|
|
cli.HandleInvoices(session)
|
|
case 3:
|
|
cli.HandleCompanies(session)
|
|
case 4:
|
|
cli.HandleAssets(session)
|
|
case 5:
|
|
cli.HandleContacts(session)
|
|
case 6:
|
|
cli.HandleContracts(session)
|
|
case 7:
|
|
cli.HandleGenericTools(session)
|
|
case 8:
|
|
cli.HandleLocations(session)
|
|
case 9:
|
|
cli.HandleNotifications(session)
|
|
case 10:
|
|
cli.HandleQuotes(session)
|
|
case 11:
|
|
cli.HandleServices(session)
|
|
case 12:
|
|
cli.HandleTags(session)
|
|
case 13:
|
|
cli.HandleUsers(session)
|
|
case 14:
|
|
cli.HandleAdmin(session)
|
|
case 15:
|
|
err := session.Logout()
|
|
if err != nil {
|
|
ui.DisplayError("Error during logout: ", err)
|
|
} else {
|
|
fmt.Println("Logout successful.")
|
|
}
|
|
fmt.Println("Exiting ServiceTrade CLI Toolbox. Goodbye!")
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|