From 23a31f53cb0d4bb1ed59c4d8e7deb938911d6224 Mon Sep 17 00:00:00 2001 From: Nanokloon Date: Tue, 1 Apr 2025 20:41:06 +0200 Subject: [PATCH] Initial commit --- CMakeLists.txt | 8 ++++++++ LICENSE | 20 ++++++++++++++++++++ README.MD | 13 +++++++++++++ func.c | 24 ++++++++++++++++++++++++ func.h | 9 +++++++++ main.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 123 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 README.MD create mode 100644 func.c create mode 100644 func.h create mode 100644 main.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7822b92 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.30) +project(breeze C) + +set(CMAKE_C_STANDARD 23) + +add_executable(breeze main.c + func.c + func.h) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7071e91 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +MIT License +Copyright (c) 2025 Nanokloon + +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/README.MD b/README.MD new file mode 100644 index 0000000..8bcef97 --- /dev/null +++ b/README.MD @@ -0,0 +1,13 @@ +# Breeze, a fun side-project for a BSc EE student. +## Are you tired of typing the same old command 100 times? +### Can you not be asked to alias commands? +#### Well then breeze has a solution for you! +# **Breeze: Custom Shortcut CLI for Frequent Commands** + +A lightweight utility that lets you define and manage aliases for commonly used shell commands with a simple interface. + +TODO: +- [ ] decide on how to save the files in config files. +- to be expanded! + + diff --git a/func.c b/func.c new file mode 100644 index 0000000..d27784b --- /dev/null +++ b/func.c @@ -0,0 +1,24 @@ +// +// Created by nano on 4/1/25. +// +#include +#include + + +int whichOption(char *defaultOptions[],char *choice) { + int res =0; + //TODO: find a way to not have to hardcode the number of choices + for (int i=0;i<5;i++) { + + if (strncmp(defaultOptions[i],choice,strlen(choice))==0) { + res = i; + } + } + return res; +} + +void printHelp(){ + printf("Usage: breeze \n"); + printf("breeze is a cli tool that helps you create shortcuts for often repeated commands.\n"); + printf("You can create local or global commands. Global commands are created with the breeze global subset of commands \n"); +} \ No newline at end of file diff --git a/func.h b/func.h new file mode 100644 index 0000000..f41fad8 --- /dev/null +++ b/func.h @@ -0,0 +1,9 @@ +// +// Created by nano on 4/1/25. +// + +#ifndef FUNC_H +#define FUNC_H +int whichOption(char *defaultOptions[],char *choice); +void printHelp(); +#endif //FUNC_H diff --git a/main.c b/main.c new file mode 100644 index 0000000..975e946 --- /dev/null +++ b/main.c @@ -0,0 +1,49 @@ +#include +#include +#include "func.h" + + +char *defaultOptions[]={"help","add","run","del","rm"}; + +void addCmd(char ** str); +void delCmd(char ** str); +void runCmd(char ** str); + +int main(int argc, char *argv[]) { + //printf("%d \n", argc); + if (argc<2) { + printHelp(); + return 0; + } + int choice = whichOption(defaultOptions,argv[1]); + printf(argv[1]); + printf("choice is %d \n",choice); + + switch (choice) { + case 1: // add + addCmd(&argv[2]); + case 2: // run + runCmd(&argv[2]); + case 3: + case 4: + delCmd(argv[2]); + default: + printf("not yet implemented\\invalid"); + return 0; + } + + return 0; +} + +void addCmd(char ** str) { //TODO: implement + printf("adding %s \n", *str); +} +void delCmd(char ** str) { //TODO: implement + printf("removed %s \n", *str); +} +void runCmd(char ** str) { //TODO: implement + printf("running %s \n", *str); +} + + +