-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor new commands c-new c-build * refactor file * clippy refactor * clippy format * new subcommands
- Loading branch information
Showing
2 changed files
with
13 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,141 +1,9 @@ | ||
# cinit | ||
|
||
# CInit - Command Line Tool for C Projects | ||
|
||
**CInit** is a command-line utility designed to simplify the workflow for creating, building, and running C projects. It provides a set of commands to automate common tasks, such as initializing project structures, compiling source files, and managing binaries. | ||
**cinit** is a CLI tool built in **Rust** to simplify the creation of new C projects. It provides a quick and standardized way to generate the basic structure for a C project, inspired by tools like `cargo` (Rust) or `zig init` (Zig). | ||
|
||
## Features | ||
|
||
- Quickly create new C projects with standard folder structures. | ||
- Build all `.c` files in the `./src/` directory. | ||
- Move compiled binaries to the `./bin/` directory. | ||
- Optionally, create a library directory with `.c` and `.h` files. | ||
- Build and immediately run a project. | ||
|
||
## Installation | ||
|
||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/yourusername/cinit.git | ||
cd cinit | ||
``` | ||
|
||
2. Build the project: | ||
```bash | ||
cargo build --release | ||
``` | ||
|
||
3. (Optional) Move the binary to a directory in your `$PATH`: | ||
```bash | ||
mv target/release/cinit /usr/local/bin/ | ||
``` | ||
|
||
## Usage | ||
|
||
To see the list of available commands, run: | ||
|
||
```bash | ||
cinit help | ||
``` | ||
|
||
### Commands | ||
|
||
#### `c-new` | ||
Create a new C project with the specified name. | ||
|
||
**Usage:** | ||
|
||
```bash | ||
cinit c-new [OPTIONS] <PROJECT_NAME> | ||
``` | ||
|
||
**Arguments:** | ||
- `<PROJECT_NAME>`: Name of the new C project. | ||
|
||
**Options:** | ||
- `--lib <FILE>`: Creates a `lib` directory with files named `<FILE>.c` and `<FILE>.h`. | ||
|
||
**Example:** | ||
```bash | ||
cinit c-new my_project --lib my_library | ||
``` | ||
|
||
This will create a directory `my_project` with the following structure: | ||
|
||
``` | ||
my_project/ | ||
├── src/ | ||
├── include/ | ||
├── lib/ | ||
│ ├── my_library.c | ||
│ └── my_library.h | ||
└── bin/ | ||
``` | ||
|
||
#### `build-c` | ||
Compile all `.c` files in the `src/` directory and move the binary to the `bin/` directory. | ||
|
||
**Usage:** | ||
|
||
```bash | ||
cinit build-c | ||
``` | ||
|
||
**Description:** | ||
- Looks for `.c` files in the `src/` directory. | ||
- Compiles them using `gcc` with the `-Wall` flag. | ||
- Places the compiled binary in the `bin/` directory. | ||
|
||
**Example:** | ||
```bash | ||
cinit build-c | ||
``` | ||
|
||
#### `build-c-run-c` | ||
Build and run your project in a single command. | ||
|
||
**Usage:** | ||
|
||
```bash | ||
cinit build-c-run-c | ||
``` | ||
|
||
**Description:** | ||
- Builds the project as described in `build-c`. | ||
- Immediately executes the resulting binary. | ||
|
||
#### `help` | ||
Prints the help message for the main command or any subcommand. | ||
|
||
**Usage:** | ||
|
||
```bash | ||
cinit help | ||
``` | ||
|
||
**Example:** | ||
To see help for a specific command, use: | ||
```bash | ||
cinit help c-new | ||
``` | ||
|
||
--- | ||
|
||
## Example Workflow | ||
|
||
1. **Create a new project:** | ||
```bash | ||
cinit c-new my_project | ||
cd my_project | ||
``` | ||
|
||
2. **Build the project:** | ||
```bash | ||
cinit build-c | ||
``` | ||
- Automatic generation of the basic structure for a C project. | ||
|
||
3. **Run the binary:** | ||
```bash | ||
./bin/main | ||
``` | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters