**************************************************** ** __ ___ __ __ v1.0 ** ** /__` |__| |__ | | | \ / \ |\/| ** ** .__/ | | |___ |___ |___ |__/ \__/ | | ** ** ** ** by Anestis Zioulis ** ** www.azioulis.com ** ****************************************************
About - Demo - Installation - Main Commands - Extra Commands - Tools - Sources
The Shelldom CLI (Command Line Interface) is a program for Windows written in C. It tries to be an MS-DOS-like operating system that supports specific commands and options.
This program was created as an assignment for the lesson "Operating Systems I" at the IHU (International Hellenic University, Serres Campus) by Anestis Zioulis.
My assignment:
Develop a shell in the programming language of your choice. If the
C
language is used, avoid using thesystem()
command and create your ownfunctions
.
Your CLI must support the following commands:dir
,move
,echo
,type
, andsort
.
Additional commands:
I did implement some additional commands that were assigned to other students in order for the CLI to feel more usable and complete than just an assignment.
I implemented these extra commands:list
,help
,cd
,create
,read
,del
,tree
, andcls
.
Notice:
This program is
NOT
case-sensitive.
To use this program, you can download the latest release and use the executable inside. Also, you can compile the source code manually or through an IDE with a bundled compiler.
- [1] Download the latest release and run the executable.
- [2] Download JetBrains CLion or another IDE that includes the compiler.
- [3] Download a tool chain, like MinGW, through the web and install it.
- [3] If you opted to compile the source code yourself.
- You downloaded the tool chain that has the compiler and installed it.
- Open
cmd
, change the directory to the folder where the source file is, and check ifgcc
is available with the following command:gcc -v
- If you see something like this, you are good to compile:
Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe Target: mingw32 Configured with: ../src/gcc-9.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-static --enable-shared --enable-threads --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libgomp --disable-libvtv --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --disable-build-format-warnings --prefix=/mingw --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --enable-nls --with-pkgversion='MinGW.org GCC Build-20200227-1' Thread model: win32 gcc version 9.2.0 (MinGW.org GCC Build-20200227-1)
- Type:
and your executable should have been compiled.
gcc -o shelldom.exe main.c
- You can run it in
cmd
by just typing it:shelldom.exe
Notice:
This program haslibraries
that work only on theWindows OS
!
These commands were required by the lesson assignment.
- DIR / LS
- Display the contents of a directory in a column (default) or a list(
-l
).dir
<option>
<path>
ls
<option>
<path>
>> dir >> ls >> dir -l c: >> ls c:/deep/ >> dir ../ >> ls -l ../linux/impostor
- Display the contents of a directory in a column (default) or a list(
- MOVE
- Move a file from one folder to another.
move
<path/file>
<path>
>> move c:/mario.txt d:/adventures/ >> move princess.jpg f:/img/ >> move ../monition.pre E:/nd/is/near/
- Move a file from one folder to another.
- ECHO
- Append a typed string to the provided file.
echo
<alphanumeric_value>
>
<file>
>> echo john55 > about.txt >> echo AbigSTRING_withText99 > sandiego.txt
- Append a typed string to the provided file.
- TYPE
- Merge all the text files in the current folder into a new one.
- If it exists, ask for permission to replace, append, or cancel.
type
/a
*.*
>
<file>
>> type /a *.* > about.txt >> type /a *.* > YotaFive.txt
I added these extra commands that were not part of the assignment, so the CLI is more usable.
- SORT
- Read 32 numbers (byte size) from a binary file, sort them, and display them.
sort
<file>
>> sort numbers.bin
- Read 32 numbers (byte size) from a binary file, sort them, and display them.
- LIST
- Show all the available commands.
list
>> list
- Show all the available commands.
- HELP
- Show details about a specific command.
help
<command>
>> help sort >> help dir
- Show details about a specific command.
- CD
- Change the current working directory.
cd
<path>
>> cd >> cd f:/ >> cd .. >> cd ../backToTheFuture/
- Change the current working directory.
- CREATE
- Save user-inserted integer numbers from 1-255 in a text or binary file, and exit with 0.
- If you want to create a binary file without
.bin
you have to use the option-b
! create
<option>
<file>
>> create binaryFile.bin >> create -b binaryFileAsWell >> create textFile.txt >> create textFileWithoutExtension
- If you want to create a binary file without
- Save user-inserted integer numbers from 1-255 in a text or binary file, and exit with 0.
- READ
- Reads text or binary files.
- In order to read binary files without the
.bin
extension, use the option-b
. read
<file>
>> read data.bin >> read -b alsoBinary >> read numbers.txt >> read readme.md
- In order to read binary files without the
- Reads text or binary files.
- DEL
- Delete a file
<file>
or files like<file*>
or all files*.*
in the current folder.del
<file>
>> del data.bin >> del dat* >> del *.*
- Delete a file
- TREE
- Displays the structure of the current folder, sub-folders, and files.
tree
<path>
>> tree >> tree f:/ >> tree .. >> tree ../backToTheFuture/
- Displays the structure of the current folder, sub-folders, and files.
- CLS
- Clear the screen from text and move the cursor to the top left.
cls
>> cls
A Microsoft function was used for this in order to bypass the
system
command due to the assignment limitation. Will not work in the CLion console window! More details for the function: https://docs.microsoft.com/en-us/windows/console/clearing-the-screen
- Clear the screen from text and move the cursor to the top left.
- EXIT
- Quits the program.
exit
>> exit
- Quits the program.
The tools I used to create this assignment.
- MingGW_GCC 9.2.0 compiler from MinGW-w64
- Jetbrains CLion (Student/full version)
- C Standard 99
Sources I used materials to create the project and readme.
- Stack Overflow
- Text to ASCII generator
- Lorem Ipsum generator
- Best-README-Template
- Microsoft CLS command