Start work on help menu and implement basic logic

This commit is contained in:
Sangelo 2023-10-05 10:53:49 +02:00
parent aa0b2f7222
commit ebf299f140
3 changed files with 56 additions and 3 deletions

View file

@ -1,5 +1,23 @@
# This is just an example to get you started. A typical binary package # src/dashinit.nim
# uses this file as the main entry point of the application. import os, strutils
import subcommands/help
import subcommands/init
proc main() =
let args = commandLineParams()
if args.len == 0:
init()
return
let subcommand = args[0].toLower()
case subcommand
of "help":
displayHelp()
of "init":
init()
else:
echo "Unknown argument '", subcommand, "'. Use 'help' for available commands."
when isMainModule: when isMainModule:
echo("Hello, World!") main()

33
src/subcommands/help.nim Normal file
View file

@ -0,0 +1,33 @@
# src/subcommands/help.nim
type
Command = tuple[
cmd: string,
desc: string
]
Argument = tuple[
arg: string,
desc: string
]
var commands: seq[Command] = @[
("help", "Displays this help message"),
("init", "Initialise a project directory with default settings"),
]
var arguments: seq[Argument] = @[
("-h", "Displays this help message")
]
proc displayHelp*() =
echo "dashinit - a powerful templating tool"
echo "\nUsage:"
echo "\tdashinit [subcommand] [arguments]"
echo "\nSubcommands:"
for command in commands:
echo "\t", command.cmd, "\t", command.desc
echo "\nArguments:"
for argument in arguments:
echo "\t", argument.arg, "\t", argument.desc

2
src/subcommands/init.nim Normal file
View file

@ -0,0 +1,2 @@
proc init*() =
echo "Initialising Project..."