From 574e41800d40becd717b6965b31df5bad3d87686 Mon Sep 17 00:00:00 2001 From: mollusk Date: Tue, 26 Nov 2019 11:31:26 -0700 Subject: [PATCH] Init project --- LICENSE | 21 ++++++++++++++ scatter.nimble | 14 ++++++++++ src/.gitignore | 3 ++ src/README.md | 8 ++++++ src/scatter.nim | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ trucks.txt | 0 6 files changed, 119 insertions(+) create mode 100644 LICENSE create mode 100644 scatter.nimble create mode 100644 src/.gitignore create mode 100644 src/README.md create mode 100644 src/scatter.nim create mode 100644 trucks.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f676eb4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Joe Martella + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/scatter.nimble b/scatter.nimble new file mode 100644 index 0000000..c21a5f9 --- /dev/null +++ b/scatter.nimble @@ -0,0 +1,14 @@ +# Package + +version = "0.1.0" +author = "mollusk" +description = "idk" +license = "MIT" +srcDir = "src" +bin = @["scatter"] + + + +# Dependencies + +requires "nim >= 1.0.2" diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..88206c6 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,3 @@ +scatter +src/scatter +.vscode \ No newline at end of file diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..9a3388b --- /dev/null +++ b/src/README.md @@ -0,0 +1,8 @@ +## Usage + +``` +git clone https://gitbutter.pw/mollusk/scatter.git +cd scatter +nimble build +./scatter -h +``` \ No newline at end of file diff --git a/src/scatter.nim b/src/scatter.nim new file mode 100644 index 0000000..26d7871 --- /dev/null +++ b/src/scatter.nim @@ -0,0 +1,73 @@ +# This is just an example to get you started. A typical binary package +# uses this file as the main entry point of the application. +import system, os, random, strutils +when isMainModule: + +#[ + proc truck() = + + while true: + write(stdout, "What kind of truck?: ") + + let myFilePath = "/home/mollusk/Documents/" + let myFile = "give_a_shit.txt" + let lines = [readLine(stdin)] + + let f = open(myFilePath & myFile, fmWrite) + defer: f.close() + + for line in lines: + f.writeLine(line.toUpper) +]# + + + proc geussNum() = + randomize() + var rng = rand(101) + while true: + stdout.write("Type a number: ") + var sroll = readLine(stdin) + var iroll = parseInt(sroll) + if rng > iroll: + echo "Number is greater" + elif rng < iroll: + echo "Number is less" + elif rng == iroll: + echo "Winner!" + quit(0) + else: + echo "not a number" + + + proc help(): string = + result = """ + +scatter [-a, -b, -k, -r] + +-a prints 'yay' +-b prints 'Oh, yeah' +-k prints 'kill' +-r Guess the number (1..100) + """ + return result + + + + var argv = commandLineParams() + + for args in argv: + case args: + of "": + echo help() + of "-a": + echo "yay" + of "-b": + echo "Oh yeah!" + of "-k": + echo "kill" + of "-r": + geussNum() + of "-h", "--help": + echo help() + else: + echo help() diff --git a/trucks.txt b/trucks.txt new file mode 100644 index 0000000..e69de29