Skip to content

Commit

Permalink
[TASK] Cleanup imports
Browse files Browse the repository at this point in the history
  • Loading branch information
on3iro committed Jul 24, 2019
1 parent d1fdeb6 commit 8bddb24
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
31 changes: 21 additions & 10 deletions src/createHandler.nim
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
import os
import parseopt
import yaml/serialization, streams

import types
import helpers
from helpers import createOMTConfig
import constants


###########
# Helpers #
###########

proc showHelpAndQuit() =
echo """
omt create <projectName>
Creates a directory by the specified project name and a default
omt.yaml configuration.
"""
quit()

###########
# Handler #
###########

proc createOMTProject*(optParser: var OptParser): void =
var projectPath: string = ""

Expand All @@ -20,13 +37,7 @@ proc createOMTProject*(optParser: var OptParser): void =
of cmdShortOption, cmdLongOption:
case optParser.key
of "h", "help":
echo """
omt create <projectName>
Creates a directory by the specified project name and a default
omt.yaml configuration.
"""
quit()
showHelpAndQuit()
else:
discard
of cmdEnd:
Expand All @@ -49,4 +60,4 @@ omt create <projectName>
outputPath = joinPath(projectPath, OMT_CONFIG)
)


quit()
35 changes: 23 additions & 12 deletions src/undoHandler.nim
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import os
import parseopt
import yaml/serialization, streams

import types
import helpers
from helpers import retrieveOMTConfigFromFile, writeSaveFile
import constants


###########
# Helpers #
###########

proc showHelpAndQuit() =
echo """
omt undo
Moves the last item from the <pickedThings> list of an omt configuration back to its <thingsList>.
-f=<fileName>, --file=<fileName>
Uses the specified YAML file instead of the default 'omt_save.yaml'.
"""
quit()

###########
# Handler #
###########

proc handleUndo*(optParser: var OptParser) =
var saveFilePath: string = SAVE_FILE

Expand All @@ -17,15 +35,7 @@ proc handleUndo*(optParser: var OptParser) =
of cmdShortOption, cmdLongOption:
case optParser.key
of "h", "help":
echo """
omt undo
Moves the last item from the <pickedThings> list of an omt configuration back to its <thingsList>.
-f=<fileName>, --file=<fileName>
Uses the specified YAML file instead of the default 'omt_save.yaml'.
"""
quit()
showHelpAndQuit()
of "f", "file":
saveFilePath = optParser.val
else:
Expand All @@ -43,6 +53,7 @@ omt undo
echo "Thing <" & thingToUndo & "> will be undone!"
echo "Writing save file..."
writeSaveFile(ConfigRoot(thingList: updatedThingList, pickedThings: pickedThings), outputPath = saveFilePath)
quit()
except:
echo "Could not undo!"
echo getCurrentException().name
Expand Down

0 comments on commit 8bddb24

Please sign in to comment.