Giter Site home page Giter Site logo

create-cpp-class's Introduction

create-cpp-class

A Node.js CLI to bootstrap the process of creating C++ classes

hero

Prerequisites

Node.js and npm

Install

npm install -g @everettblakley/create-cpp-class

Disclaimer

This package will create files, and potentially directories, within your file system. Currently, the program will determine the files that it needs to create, and will copy over the required templates, overwriting any files that have the same name. The program will show you the files that it is going to generate, and ask if that looks right to you. It will not check if the file already exists, so be careful to not specify a class that already exists, or it will be over written.

The program will display a disclaimer before it runs, just to be sure you are aware:

  DISCLAIMER
Be aware that this program will overwrite any files that match any files specified in the output. You will have an opportunity to abort before any writes occur. Please be aware of the values you use.
? Proceed with this program? (Y/n)

Usage

This CLI will create a C++ class based on parameters you pass in, combined with some user input on the command line.

Basic Usage

Without any arguments, the CLI will walk you through all the prompts, and ask what you want to name the class, and everything else.

create-cpp-class

This will ask you the following questions regarding the new class:

  1. Do you accept the terms of the Disclaimer

  2. The name of the class you want to create

    • Some notes about class names:
      • Note that spaces will be ignored on input
      • Class can only contain A-Z (lowercase or uppercase), 0-9, and underscores(_)
      • Any errors will display a message
  3. The output directory of the header file (default is ./include)

  4. The file extension of the header file (default is .h, other options are .hpp andNone

  5. If you want to include a source file for class implementation (default is yes). If so, then it will ask:

    1. The output directory of the source fill (default is ./src)
    2. The file extension of the source file (default is .cpp, other options are .cc and .cxx)
  6. The CLI will display the files that it is going to create based on your options, and ask you if you want to continue. (default is yes)

Then the CLI will process your configuration, create the files, and populate them with the relevant information!

To see the templates used for the header and source files, see the respective files here

Accept Defaults: --yes (-y)

To accept all defaults and simply run the creation script, use --yes (or -y)

create-cpp-class --yes

This will use all defaults (listed here), but will still ask for a class name (unless you [declare a class name](#Declare class name))

Declare class name: --class-name(-c)

If you don't want to go through the class name prompts, you can use the --class-name (or -c) arg to pass it in. The class name should follow the conditions laid out in the [basic usage](#Basic Usage), else you will be required to input one from the prompts.

create-cpp-class -c AwesomeClassName

This will still require you to agree to the disclaimer, and to set the appropriate header/source file and extensions, unless used with the accept defaults flag

Exclude Source Files: --no-source (-n)

If you don't want to use a separate file for class implementation (i.e. have the class all contained in the header file), pass in the --no-source (or -n) flag and these prompts will be skipped. You will still need to to agree to the disclaimer, and set appropriate header extension and locations, unless used with the accept defaults flag

Dry Run: --dry-run (-d)

If you just want to see what the CLI will produce, use the --dry-run (or -d) flag. This will bypass the disclaimer , but you will still need to answer the other prompts, unless used with the accept defaults flag NO FILES WILL BE WRITTEN TO YOUR DISK WITH THIS COMMAND

Advanced Usage

If you don't like all the prompts, or you find that you don't need to specify the header extensions and locations every time, use the following command to get through it faster

create-cpp-class -y -c AwesomeClassName

This will create the following files:

./
| -> include/AwesomeClassName.h
| -> src/AwesomeClassName.cpp

To see what this command will output before committing to it, just run create-cpp-class -y -c AwesomeClassName -d

Defaults

The default settings define the class in a header file, with a source file (or implementation) containing class implementations. The default header file extension is .h and the default source file extension is .cpp, with the header being placed in a directory called include and source being placed in a directory called src

Authors

This code was written while procrastinating an assignment by Everett Blakley

Contribution

Contributions are welcome via pull-requests to the master branch

License

This project is using the a standard MIT License

create-cpp-class's People

Contributors

everettblakley avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.