{"id":15612404,"url":"https://github.com/euberdeveloper/cscell","last_synced_at":"2025-03-29T15:13:17.969Z","repository":{"id":62565611,"uuid":"296667965","full_name":"euberdeveloper/cScell","owner":"euberdeveloper","description":"A framework made with python for C cli projects","archived":false,"fork":false,"pushed_at":"2020-09-19T21:47:40.000Z","size":68334,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T13:46:30.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/euberdeveloper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-18T16:02:07.000Z","updated_at":"2020-09-20T12:22:34.000Z","dependencies_parsed_at":"2022-11-03T16:15:27.436Z","dependency_job_id":null,"html_url":"https://github.com/euberdeveloper/cScell","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2FcScell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2FcScell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2FcScell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euberdeveloper%2FcScell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/euberdeveloper","download_url":"https://codeload.github.com/euberdeveloper/cScell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246200323,"owners_count":20739566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T06:42:35.242Z","updated_at":"2025-03-29T15:13:17.938Z","avatar_url":"https://github.com/euberdeveloper.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cScell\nA framework written with python, in order to quickly create C shell projects on Linux envinronment.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/euberdeveloper/cScell/blob/master/docs/example.gif\"\u003e\n        \u003cimg src=\"https://github.com/euberdeveloper/cScell/raw/master/docs/example.gif\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Install\n\n**Note**: this package is thought to be used by **Linux** platforms.\n\nYou can install cScell with `pip` or `pip3`:\n\n```bash\n$ pip3 install cScell\n```\n\nThe package is usually used as a global module. It is possible that a warning will appear during the installation, saying that the location of the package is not on the `$PATH` variable. In order to be able to use it from any directory, add that location to the `$PATH` variable.\n\n## Usage\n\n### Syntax\n\nThe syntax of the command is:\n\n```bash\ncScell [app_name] [commands_json_path] [output_dir_path]\n```\n\nThe three parameters are:\n* __app_name__: The name of the project. Default: `scell_project`.\n* __commands_json_path__: The path to the json file describing the commands of the shell program. Default: `./commands.json`.\n* __output_dir_path__: The path where the project directory will be created. Default: `./`.\n\n### Examples\n\nThis example will create in the current folder a project called \"myProject\":\n\n```bash\ncScell myProject\n```\n\nThis example will create in the parent folder a project called \"myProject\", with the commands described in \"my-commands.json\":\n\n```bash\ncScell myProject ./my-commands.json ../\n```\n\n### Usage as local module:\n\nThe module could be actually used also as a local module, here is an example:\n\n```python\nfrom cScell.cScell import generate_scell\n\nAPP_NAME = 'myProject'\nJSON_COMMANDS = './my-commands.json\nOUTPUT_PATH = '../'\n\ngenerate_scell(APP_NAME, JSON_COMMANDS, OUTPUT_PATH)\n```\n\n## Json format\n\nYou can describe the **commands** of your c shell program with a **json file**.\n\nIn the commands json file:\n* Each root **key** is the name of a **command** of the shell. Its value must be an **object**.\n* The special `_arguments` **command** is the command that could be executed when the user passes command line arguments to the program.\n* An exception for what was said above is the `promptSymbol` **key**, that specifies the **symbol** displayed **before each line of the prompt**. If **not specified**, its value will be `\u003e\u003e`.\n* For **each command**, the `function` property indicates the **name** of the function that **handles** that command.\n* For **each command**, the `arguments` property indicates the arguments accepted by that command. Its value must be an **object**.\n* For **each arguments object**, every **key** is the **name** of an argument and its value must be an **object**.\n* For **each argument value**, the key `type` is mandatory and describes the **variable type** of the argument. The possible options are: `int`, `long`, `float`, `double`, `char`, `char*`, `array\u003ctype\u003e` (where `type` is one of the precedent types).\n* For **each argument value**, the key `alias` is not mandatory and describes an **alias** (**single character**) that could be used instead of the extended argument name.\n* For **each argument value**, the key `default` is not mandatory. If it is not specified, the argument is mandatory when the command is typed by the user. NB: The **bool** type is **always false as default**. The **array** type **can only be \"NULL\"** as default if it is not a required argument.\n* For **each argument value**, the key `min` is not mandatory. It can be used with **numeric** types and indicates that the passed argument value must be **bigger or equal** than the value of **min**.\n* For **each argument value**, the key `max` is not mandatory. It can be used with **numeric** types and indicates that the passed argument value must be **lower or equal** than the value of **max**.\n* For **each argument value**, the key `description` is not mandatory. It is the displayed **description for the argument** when the command **help** is executed.\n* For **each command**, the key `description` is not mandatory. It is the displayed **description for the command** when the command **help** is executed.\n\nAn example:\n\n```json\n{\n    \"promptSymbol\": \"\u003e\u003e\u003e\",\n    \"_arguments\": {\n        \"function\": \"arguments\",\n        \"arguments\": {\n            \"thing\": {\n                \"type\": \"int\",\n                \"alias\": \"t\",\n                \"default\": 1,\n                \"min\": 0,\n                \"description\": \"The thing argument description\"\n            },\n            \"stuff\": {\n                \"type\": \"float\",\n                \"alias\": \"s\",\n                \"max\": 10,\n                \"description\": \"The stuff argument description\"\n            },\n            \"ware\": {\n                \"type\": \"array\u003cchar*\u003e\",\n                \"alias\": \"w\",\n                \"default\": \"NULL\",\n                \"description\": \"The ware argument description\"\n            }\n        }\n    },\n    \"increment\": {\n        \"function\": \"inc\",\n        \"arguments\": {\n            \"number\": {\n                \"type\": \"int\",\n                \"alias\": \"n\",\n                \"description\": \"The number to increment\"\n            },\n            \"amount\": {\n                \"type\": \"int\",\n                \"alias\": \"a\",\n                \"default\": 1,\n                \"description\": \"How much will the number incremented\"\n            }\n        },\n        \"description\": \"Increments a number\"\n    },\n    \"add\": {\n        \"function\": \"add\",\n        \"arguments\": {\n            \"first\": {\n                \"type\": \"int\",\n                \"alias\": \"x\",\n                \"description\": \"The first addend\"\n            },\n            \"second\": {\n                \"type\": \"int\",\n                \"alias\": \"y\",\n                \"description\": \"The second addend\"\n            }\n        },\n        \"description\": \"Adds two addends\"\n    },\n    \"concat\": {\n        \"function\": \"concat\",\n        \"arguments\": {\n            \"strings\": {\n                \"type\": \"array\u003cchar*\u003e\",\n                \"default\": \"NULL\",\n                \"description\": \"The strings to concat\"\n            },\n            \"reverse\": {\n                \"type\": \"bool\",\n                \"alias\": \"r\",\n                \"description\": \"If the strings will be in reversed order\"\n            }\n        },\n        \"description\": \"Concats an array of strings\"\n    },\n    \"quit\": {\n        \"function\": \"quit\",\n        \"description\": \"closes the program\"\n    }\n}\n```\n\n## Result\n\nAt the end of execution, a **project folder** called as you specified for the `app_name` argument will be created in the `output_dir_path` that you specified.\n\nThat folder is **structured** as specified below:\n* There will be a `compile.sh` bash script. It is the script to **compile** the **c generated source code**. If it is not already executable, you can execute `sudo chmod +x compile.sh`.\n* There will be a `[app_name].c` file, named as the **name of the project**. It will contain the **main function** of the program, it imports the **commands interpreter** generated by the module and the **commands handlers** that you should implement and will **run the shell loop**.\n* There will be the `shellutils` folder, containing all the `libraries` that make the shell work. These libraries are:\n    - `colour`, for a coloured output\n    - `constructs`, containing only header files, a `boolean.h` for the boolean enum and a `sh_state.h` for the state of a command enum.\n    - `logger`, used by the shell to log errors or warnings.\n    - `text`, containing all the text functions and the advanced terminal.\n    - `shell_utils`, used by the shell_commands library\n    - `shell_commands`, the only one that **depends** on the `commands.json` file passed before creating the project. It will contain the code that **parses the shell commands** prompted by the user and **calls the right function handler**\n* There will be the `handlers` folder, containing the `handlers.h` and `handlers.c` files. You will **edit** the `handlers.c` files in order to define the code that will be executed when the user prompts a specific command.\n\nThere will be also **three** variables exported by `shell_commands.h`:\n* `char *sh_last_command`: It is the string variable containing the last prompted command\n* `char *sh_prompt_symbol`: It is the variable whose value is the string that specifies the **symbol** displayed **before each line of the prompt**.\n* `bool sh_use_advanced_terminal`: It is the boolean variable that determines if the **advanced terminal** will be used. The advanced terminal makes possible to the user to use the **up and down arrows** to navigate the **commands cronology**. Its default value is `true`, but you can change it before the `sh_loop();` call in the `[app_name].c` file.\n\nTo start the program you just need to execute:\n```bash\ncd [your_project_dir]\nsudo chmod +x ./compile.sh\n./compile.sh\n./[your_app_name]\n```\nThis will compile the c code and start the generate executable program.\n\nYou should **edit** the `handlers.c` file to define the behaviour of each command.\n\n## What the framework does\n\nUnder the hood:\n* All arguments containing **hyphens** in the name will be purged with **underscores**.\n* If the `_arguments` command was defined, if the users passes **command line arguments** they will be parsed and the corrispondent handler executed.\n* An **infinite loop** that **listens** for the user's commands will be then executed.\n* All **empty prompted lines** will be ignored.\n* After a command is prompted, the program will **check if the command exists**. If not, it will **display a proper error message**.\n* If the command exists, it will be **properly** parsed.\n* If a **required argument** misses, a **value** is invalid, a **value** misses or does not matches **provided numerical ranges**, an error will be displayed.\n* The **extended** argument names should be preceded by two hyphens `--` while the **aliased** argument names by a single hyphen `-`.\n* If a **value without argument** will be passed, a warning will be displayed, but it will not block the command.\n* If all checks pass and the command is correctly parsed, the corrispondent **handler function** is called with the parsed arguments. You can easily **edit** the `handlers.c` file and implement the handlers, which by default print the command name.\n* If the `help` command is prompted, the documentation for all the commands will be displayed\n* If the `help [command]` command is prompted, the documentation for the given command will be displayed\n\n## Notes\n\n* This framework works only for **Linux**.\n* Only **named** arguments are allowed. This means that all commands will be like `add -x 1 -y 2` or `concat --strings first second third` but commands like `add 1 2` will not be allowed.\n* If a string parameter **contains spaces**, you can include it inside double apix such as `concat --strings \"first string\" \"second string\"`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuberdeveloper%2Fcscell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feuberdeveloper%2Fcscell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuberdeveloper%2Fcscell/lists"}