From 9e4c713c24973656586ef71d4e1e28b542c79c14 Mon Sep 17 00:00:00 2001 From: Caznix Date: Sun, 28 Jul 2024 15:13:01 -0400 Subject: [PATCH] add build.vsh --- .editorconfig | 8 ++++++++ .gitattributes | 7 +++++++ .gitignore | 24 ++++++++++++++++++++++++ build.vsh | 17 +++++++++++++++++ src/init.v | 14 +++++++++++--- src/main.v | 13 +++++++------ 6 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 build.vsh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..01072ca --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.v] +indent_style = tab diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f4011a7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +* text=auto eol=lf +*.bat eol=crlf + +**/*.v linguist-language=V +**/*.vv linguist-language=V +**/*.vsh linguist-language=V +**/v.mod linguist-language=V diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b86a91 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Binaries for programs and plugins +main +comet +*.exe +*.exe~ +*.so +*.dylib +*.dll + +# Ignore binary output folders +bin/ + +# Ignore common editor/system specific metadata +.DS_Store +.idea/ +.vscode/ +*.iml + +# ENV +.env + +# vweb and database +*.db +*.js diff --git a/build.vsh b/build.vsh new file mode 100644 index 0000000..d1c413b --- /dev/null +++ b/build.vsh @@ -0,0 +1,17 @@ +#!/usr/bin/env -S v + +fn sh(cmd string) { + println('> ${cmd}') + print(execute_or_exit(cmd).output) +} + +sh('ls') + +rmdir_all('build') or {} +mkdir('build')! + +result := execute('mv *.v build/') +if result.exit_code ! /= { + println(result.output) +} + diff --git a/src/init.v b/src/init.v index 83bfc74..eacaea5 100644 --- a/src/init.v +++ b/src/init.v @@ -2,12 +2,20 @@ module initalizer import os +pub const working_dir = os.home_dir() + '/.comet' struct State { uninitalized int initalized int } +pub fn check_initalization() !bool { + if ! os.exists(working_dir) { + println('it doesnt exist') + return true + } else { + return false + } +} - -fn initalize(init_type int) { - +pub fn initalize() { + println("test initalize") } \ No newline at end of file diff --git a/src/main.v b/src/main.v index 64a5702..159eea5 100644 --- a/src/main.v +++ b/src/main.v @@ -5,13 +5,20 @@ import cli import initalizer + fn main() { mut app := cli.Command{ name: 'Comet' description: 'The package manager you never knew you needed' usage: 'test' + pre_execute: fn (cmd cli.Command) ! { + if initalizer.check_initalization() ! { + println('initalization required') + } + } execute: fn (cmd cli.Command) ! { println('asdfasd') + initalizer.initalize() return } commands: [ @@ -27,12 +34,6 @@ fn main() { println('test') } } - cli.Command{ - name: 'sd' - execute: fn (cmd cli.Command) ! { - cli.print_help_for_command(cmd) ! - } - } ] } app.setup()