CLI application to create almost any programming language files from your terminal! It has been developed to be used in any bash or shell, also in IDEs, text editors with console or terminal integrated. The app is developed in C++ and currently is made for Linux Systems. But, with your help and contribution we together could extend this to other type of systems.
The idea is to develop a Command Line Interface program for allowing CLI lovers to create their favorites code files wherever directory they are. The file will be generated with a comment header which will contain information about the file and the client. For example, File Name, Date of Creation, Author, and a brief description. Although, depends on the type of language, it creates a trivial sample code like hello world in a main function or in a proper function. After that, you can open it with your favorite editor (i.e vi, vim, etc.). The CLI interface code relies on docopt.cpp library for making easier the creation of command-line interfaces.
For more information on docopt.cpp
, please see this page.
This is a very humble project. I am not using any framework to develop this project. However, it uses autotools for generating the configuration files and the Makefile to build and install the project. I am learning while doing, so may there be lots of mistakes and errors in designing and coding. I'll be thankful for any recommendation for improving the code.
- C++11
- autotools (autoconf, automake, libtool)
$ sudo apt update
$ sudo apt install autotools-dev
$ sudo apt install autoconf
$ sudo apt install libtool
To get the code, build, and install the CLI app; follow the commands below:
$ git clone https://github.com/alucardthefish/CodeNowHere.git
$ cd CodeNowHere
$ git submodule init
$ git submodule update
$ git config submodule.googletest.ignore untracked
$ ./autogen.sh
$ ./configure
$ make
After building you can install it in your machine this way:
$ sudo make install
make install can be reverted through the uninstall command:
$ sudo make uninstall
In the case you are building the project with an old C++ compiler and get an error message like this:
Error this file requires compiler and library support for the ISO C++ 2011 standard. This support may be enabled with the -std=c++11 or -std=gnu++11 compiler options.
Then, you can run the config file this way:
$ ./configure CXXFLAGS="-std=gnu++11"
A bash script build_local.sh
is provided to compile it locally in the build directory. You can edit it with your compiler.
$ ./build_local.sh
$ cd build
# Example
$ ./cnh this File.ext -a "Author One" -d "Description one"
You can download a version package from release page. The package will have this format: cnh-x.y.z.tar.gz (x, y, and z are numbers).
- From the terminal, change to the directory where cnh-x.y.z.tar.gz has been downloaded.
- Type the following to extract the file to the current directory:
$ tar -zxvf cnh-x.y.z.tar.gz
- then install:
$ ./configure CXXFLAGS="-std=gnu++11"
$ sudo make install
Type in shell:
$ cnh --help
Usage:
cnh this <filename> [-a <author>] [-d <desc>] [--cr]
cnh these <filenames>... [-a <desc>] [--cr]
cnh bunchof <numfiles> [--ext=<fileext>] [--author | -a <author>]
cnh (-h | --help)
cnh --version
Options:
-h --help Show this screen.
--version Show version.
-a <author>, --author <author> Set the file author.
-d <desc>, --desc <desc> Set the file description.
--cr Set a copyright line to comment header.
--ext=<fileext> File extension [default: .cpp]
Filename is mandatory. Depending on the extension file it will create the header commentary.
- Creating a python code file
$ cnh this sample.py
cnh generates a python file named sample.py
with the following header comment:
# ****************************************************************************
# File: sample.py
# Author: UserName
# Created: Sun Jan 5 03:18:05 2020
# Description:
# ****************************************************************************
def main():
print("Hello World!")
if __name__ == "__main__":
main()
If option -a or --author is not passed, it takes the username from the system by default.
- Creating a code file in C++ with options arguments
$ cnh this sample.cpp -a "John Doe" -d "Sample of code file creation"
cnh generates a c++ file named sample.cpp
with the following header comment:
// ****************************************************************************
// File: sample.cpp
// Author: John Doe
// Created: Sun Jan 5 03:27:15 2020
// Description: Sample of code file creation
// ****************************************************************************
#include <iostream>
using namespace std;
int main(int argc, char * argv[]) {
cout << "Hello World" << endl;
return 0;
}
- Adding copyright comment with --cr option:
$ cnh this sample.cpp -a "John Doe" -d "Sample of code file creation" --cr
The output would is shown below:
// ****************************************************************************
// File: sample.cpp
// Author: John Doe
// Created: Thu Feb 20 17:23:41 2020
// Copyright (c) 2020 John Doe. All rights reserved.
// Description: Sample of code file creation
// ****************************************************************************
#include <iostream>
using namespace std;
int main(int argc, char * argv[]) {
cout << "Hello World" << endl;
return 0;
}
- For creating various code files at once you can do it passing their names as follows:
$ cnh these MyFileA.py MyFileB.py MyFileC.py -a "John Doe" --cr
- For creating a number of code files at once without specifying names only the extension file:
$ cnh bunchof 5 --ext .py
The created files come with blank description in their comment headers.
- Ada
- Agda
- Alef
- AppleScript
- Awk
- B
- Bash
- Boo
- C
- C-INTERCAL
- C#
- C++
- Ceylon
- Clojure
- Cobol
- Cobra
- CoffeeScript
- ColdFusion
- Crystal
- Css
- D
- Dart
- E
- ECMAScript
- Egison
- Elixir
- Elm
- Erlang
- Euphoria
- F#
- Factor
- Falcon
- Fortran
- Fp
- Gap
- Gnuplot
- Go
- Gosu
- Groovy
- Haskell
- Html
- Icon
- Imba
- Io
- J
- Janet
- Java
- JavaScript
- Julia
- Json
- Kotlin
- Logo
- Lua
- Nemerle
- ObjectiveC
- Pawn
- Pascal
- Perl
- Php
- Picat
- PL/SQL
- Prolog
- Pony
- Python
- Qore
- R
- Ruby
- Rust
- Scheme
- Sql
- Swift
- Toml
- VisualBasic
- Xml
- Yaml
Whether you enter a different programming language from the list above or an unknown file into the program, it will ask you for the inline comment character to create the header commentary. Otherwise, the comment header is omitted.
Project uses the Google Test library for Unit Testing locally as part of the code in the submodule googletest. For testing, go to tests/ directory and write some tests.
To run the tests; type the following from base folder /
$ make check
Please read our Contributing guidelines, and Code of Conduct.
Feel free to create issues and Pull Requests for improving this project. For instance, you can support it extending this utility adding more programming languages options, requesting new features, and reporting bugs.