Skip to content

Commit

Permalink
refactor: rewrite subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
WingLim committed May 21, 2021
1 parent 40e7449 commit 263e5f2
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions Sources/MicFix/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,47 @@

import Foundation

let version = "1.1.3"
let version = "1.2.0"

func start() {
func startCommand() {
MicFix().start()
RunLoop.current.run()
}

func helpCommand() {
let help = """
Fix Headset/Headphone Micphone in Hackintosh with AppleALC.
usage:
MicFix <command>
commands:
help Shows help
start Start the MicFix process
version Prints the version
"""
print(help)
}

func cli() {
let args = CommandLine.arguments
if args.count == 2 {
if args[1] == "version" {

if args.count == 1 {
startCommand()
} else if args.count == 2 {
switch args[1] {
case "version":
print(version)
} else if args[1] == "help" {
let help = """
Fix Headset/Headphone Micphone in Hackintosh with AppleALC.
usage:
manual: nohup MicFix &
brew: brew services start winglim/taps/micfix
"""
print(help)
case "help":
helpCommand()
case "start":
startCommand()
default:
print("Unknown command")
}
} else {
MicFix().start()
RunLoop.current.run()
print("Too many arguments")
}
}

start()
cli()

0 comments on commit 263e5f2

Please sign in to comment.