Skip to content

utox39/new-project-cli

Repository files navigation

new-project-cli

asciicast

Description

Create a new project from the terminal.

This tool will help you create a minimal structure for your new project.

You can create new:

  • Bash projects
  • C projects
  • Cpp projects
  • Go projects
  • Java projects
  • Lua projects
  • OCaml projects
  • PHP projects
  • Python projects
  • Ruby projects
  • Rust projects
  • Vlang projects
  • Web projects (html, css, javascript)

and open them in:

Why these programming languages?

I mainly based myself on the percentages reported by Stackoverflow's 2023 Developer Survey for the "Programming, scripting, and markup languages" section, and I selected the most used languages and those that I consider to be the most promising or interesting

Default development directories tree

$HOME
└──Developer
   └── projects
       ├── bash_projects
       ├── c_projects
       ├── cpp_projects
       ├── go_projects
       ├── java_projects
       ├── lua_projects
       ├── ocaml_projects
       ├── php_projects
       ├── python_projects
       ├── ruby_projects
       ├── rust_projects
       ├── vlang_projects
       └── web_projects

Projects created via commands

E.g: To create a new Rust project, newproject use the following command:

$ cargo new project_name

So it use the default command to create a new cargo package.

The same is for Ruby, OCaml and Vlang.

Requirements

To create a Rust projects

To create a Ruby projects

To create a OCaml projects

Installation

Easy as you can see here:

$ pip install newproject-cli

Please note: After installing newproject with pip if you have not added ~/.local/bin (macOS/Linux) to $PATH you will be asked to do so with a warning that should look like this:

WARNING: The script newproject is installed in '/home/ubuntu/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Usage

Create a new python project

$ newproject --python project_name

Create a new web project

$ newproject --web project_name

This command will create a very simple web project with this structure:

project_name
├── README.md
├── index.html
├── scripts
│   └── index.js
└── styles
    └── style.css

Create a new project and open it in Visual Studio Code

WARNING: In order to open the new project in your favorite IDE you need to have the shell command

$ newproject --code --python project_name

Customization

The default yaml config file is located in site_packages

How can I find the default config file?

$ pip3 show newproject-cli
Name: newproject-cli
Version: 0.x.x
Summary: A command-line tool to create new projects
Home-page: https://github.com/utox39/new-project-cli
Author: utox39
Author-email: francescomoccaldi39@gmail.com
License: MIT
Location: path/to/site-packages <-- LOOK HERE
Requires: jsonschema, pyyaml, rich, typer, typing_extensions
Required-by:

$ cd path/to/site-packages/newproject/config

YAML config file in ~/.config/newproject (macOS/Linux only)

The default configuration file is located in the site_packages folder, but you can also use a configuration file that you can create in the ~/.config/newproject folder.

ATTENTION: Using this config file does not involve updating to the latest features involving the default config file (located in the site_packages), therefore it requires manual intervention

Let's see how you can do it:

  • Create the configuration folder and the YAML config file
$ cd ~/.config
$ mkdir newproject
$ touch newproject_config.yaml
  • Open the YAML file in your editor of choice

  • Copy the contents of this file into the YAML file

  • Done

Customize the Development folder

In newproject_config.yaml:

development_dir_path: path/to/your/development/folder/

E.g:

development_dir_path: Documents/projects/

Customize a programming language projects folder

In newproject_config.yaml:

project_folder_names:
  python_projects_dir_name: python_projects

Customize a programming language file content

In newproject_config.yaml:

You can customize the content of the files only of the following programming languages:

  • Bash
  • C
  • Cpp
  • Go
  • Java
  • Lua
  • PHP
  • Python
  • Web projects (html, css, javascript)
cpp:
  file_content: |
    #include <iostream>

    int main()
    {
        std::cout<<"hello world"<<'\n';
        return 0;
    }

Customize the .gitignore for a specific programming language

In newproject_config.yaml:

You can customize the content of the .gitignore only of the following programming languages:

  • Bash
  • C
  • Cpp
  • Go
  • Java
  • Lua
  • PHP
  • Python
  • Web projects (html, css, javascript)
python:
  gitignore_content: |
    DS_Store
    .env
    .vscode/
    .idea/
    test/
    venv/

Customize the default .gitignore

default_gitignore_content: |
  .DS_Store
  .env
  .vscode/
  .idea/
  test/
  foo/

Roadmap

  • Improve customization
  • Add more programming languages
  • Add more IDE
  • Improve user output and experience
  • Publish this project to package managers

Contributing

If you would like to contribute to this project just create a pull request which I will try to review as soon as possible.

Releases

No releases published

Packages

No packages published

Languages