commit 58ec1de9e1a5d6f6b9241b58f43438e952b270b9 Author: Lucas Colombo Date: Thu Mar 28 20:13:49 2024 -0300 🍾 Initial commit diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..b582f2c --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[registries.lugit] +index = "sparse+http://lugit.local/api/packages/lucodear/cargo/" + +[registry] +global-credential-providers = ["cargo:token"] diff --git a/.cocorc b/.cocorc new file mode 100644 index 0000000..0f0d4e7 --- /dev/null +++ b/.cocorc @@ -0,0 +1,4 @@ +# https://github.com/lucas-labs/coco config + +askScope: false +useEmoji: true \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2520a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +.data/*.log +.task diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..4ea2c1b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + // debug rust on windows + { + "name": "debug: lool", + "type": "cppvsdbg", + "request": "launch", + "program": "${workspaceFolder}/target/debug/lool.exe", + "args": [ + "server", + "--force" + ], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [ + { + "name": "KURV_HOME", + "value": "${workspaceFolder}" + } + ], + "externalConsole": true, + "preLaunchTask": "cargo: build" + }, + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a5ad631 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,25 @@ +{ + "files.exclude": { + // ⚙️ config + "Taskfile.yaml": true, + ".cocorc": true, + ".task": true, + ".cargo": true, + // "Cargo.toml": true, + + // 📦 + "Cargo.lock": true, + "target": true, + + // 📝 readmes + "**/**/README.md": true, + "LICENSE": true, + + // 🗑️ + "check_size.py": true, + "*.code-workspace": true, + ".gitignore": true, + ".vscode": true, + ".git": true, + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..517eb82 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,19 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "cargo: build", + "type": "shell", + "command": "cargo build", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$rustc" + ] + }, + ] +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..24099fe --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "lool" +version = "0.0.0-alpha.0" +edition = "2021" +description = "🧳 » lool » lucode.ar rust common utilities" +authors = ["Lucas Colombo "] + +[profile.release] +strip = true +lto = true +codegen-units = 16 +opt-level = 'z' +panic = "abort" +rpath = false +overflow-checks = false +debug = 0 +debug-assertions = false + +[dependencies] +eyre = { version = "0.6.12", default-features = false, features = ["auto-install"] } +indoc = "2.0.4" + +[[bin]] +name = "lool" +path = "src/main.rs" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..54139c6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Lucas Colombo + +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. diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..08eb026 --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,25 @@ +# https://taskfile.dev + +version: '3' + +tasks: + run:watch: + desc: 🚀 watch lool + cmds: + - cargo watch -c -x "run -- --version" + + build:watch: + desc: 🚀 watch lool «build» + cmds: + - cargo watch -c -x "build" + + build: + desc: ⚡ build lool «release» + cmds: + - cargo build --release + - python check_size.py + + fmt: + desc: 🚀 format lool + cmds: + - cargo +nightly fmt --all \ No newline at end of file diff --git a/check_size.py b/check_size.py new file mode 100644 index 0000000..0c6dc5e --- /dev/null +++ b/check_size.py @@ -0,0 +1,56 @@ +""" +small script to run after build, to check if there was a significant +change on executable size, compared to the previous build. + +this aims to detect unwanted big differences before it's too late +""" + + +import os +import pathlib + +curr_dir = pathlib.Path(os.getcwd()) +sizefile_path = pathlib.Path(curr_dir.joinpath('.task')) + + +def bad(txt): + return '\033[91m' + txt + '\033[0m' + + +def good(txt): + return '\033[92m' + txt + '\033[0m' + + +def head(txt): + return '\033[94m' + txt + '\033[0m' + + +files = { + 'release': curr_dir.joinpath('target/release/lool.exe'), + 'debug': curr_dir.joinpath('target/debug/lool.exe'), +} + +print("\n🧉 » exe file sizes change\n") + +for key, exe in files.items(): + if exe.is_file(): + sizefile = sizefile_path.joinpath(key) + new_size: float = os.stat(exe).st_size / 1024 + old_size: float + + try: + with open(sizefile, 'r') as f: + old_size = float(f.read()) + except FileNotFoundError: + old_size = 0 + + # diff: str = f'{old_size:.0f}kb' + diff = new_size - old_size + diff_str = f"{'+' if diff > 0 else '=' if diff == 0 else ''}{diff:.0f}kb" + + fmt = bad if diff > 10 else good + + sizefile.parent.mkdir(parents=True, exist_ok=True) + + with open(sizefile, 'w') as f: + f.write(f'{new_size}') diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..f50e61a --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,6 @@ +max_width = 100 +array_width = 80 +chain_width = 100 +comment_width = 80 +imports_indent = "Block" +imports_granularity = "One" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..465a5e5 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,7 @@ +use eyre::Result; + +fn main() -> Result<()> { + println!("Hello World"); + + Ok(()) +} diff --git a/🧳 lool.code-workspace b/🧳 lool.code-workspace new file mode 100644 index 0000000..d7fc36a --- /dev/null +++ b/🧳 lool.code-workspace @@ -0,0 +1,20 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "terminal.integrated.env.windows": { + // allows to run the command in the terminal for development purposes + "PATH": "${workspaceFolder}/target/debug;${env:PATH}", + }, + "lucodear-icons.activeIconPack": "rust_ferris", + "lucodear-icons.folders.associations": { + ".cargo": "rust", + }, + "lucodear-icons.files.associations": { + + } + } +}