Skip to content

Commit 329829a

Browse files
committed
FileSystem.Cli implemented
1 parent 6b22862 commit 329829a

File tree

13 files changed

+3035
-1
lines changed

13 files changed

+3035
-1
lines changed

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
*.pid.lock
11+
12+
# Directory for instrumented libs generated by jscoverage/JSCover
13+
lib-cov
14+
15+
# Coverage directory used by tools like istanbul
16+
coverage
17+
18+
# nyc test coverage
19+
.nyc_output
20+
21+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
22+
.grunt
23+
24+
# node-waf configuration
25+
.lock-wscript
26+
27+
# Compiled binary addons (http://nodejs.org/api/addons.html)
28+
build/Release
29+
30+
# Dependency directories
31+
node_modules
32+
jspm_packages
33+
34+
# Optional npm cache directory
35+
.npm
36+
37+
# Optional REPL history
38+
.node_repl_history

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"cSpell.words": [
3+
"Codeburst",
4+
"scandir",
5+
"snipercode",
6+
"Twilio"
7+
]
8+
}

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,74 @@
11
# SniperCode.FileSystem.Cli
2-
A command line interface for file handling using SniperCode.FileSystem
2+
3+
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/Sniper-Code/SniperCode.FileSystem.Cli)
4+
![GitHub last commit](https://img.shields.io/github/last-commit/Sniper-Code/SniperCode.FileSystem.Cli)
5+
![GitHub](https://img.shields.io/github/license/Sniper-Code/SniperCode.FileSystem.Cli)![GitHub top language](https://img.shields.io/github/languages/top/Sniper-Code/SniperCode.FileSystem.Cli)
6+
7+
## **Table of Contents**
8+
9+
- [SniperCode.FileSystem.Cli](#snipercodefilesystemcli)
10+
- [**Table of Contents**](#table-of-contents)
11+
- [**Introduction**](#introduction)
12+
- [**Installation**](#installation)
13+
- [**Uninstall**](#uninstall)
14+
- [**Usage**](#usage)
15+
- [**References**](#references)
16+
- [**Articles**](#articles)
17+
- [**Packages**](#packages)
18+
- [**ToDo**](#todo)
19+
- [**Release**](#release)
20+
21+
## **Introduction**
22+
23+
A command line interface for file handling using [SniperCode.FileSystem](https://github.com/Sniper-Code/SniperCode.FileSystem)
24+
25+
## **Installation**
26+
27+
To install the package, run the following command:
28+
29+
```bash
30+
npm install sniperCode.filesystem.cli
31+
```
32+
33+
## **Uninstall**
34+
35+
To uninstall SniperCode.FileSystem, run `npm uninstall sniperCode.filesystem.cli`.
36+
37+
## **Usage**
38+
39+
This package is a command line interface for file handling using [SniperCode.FileSystem](https://github.com/Sniper-Code/SniperCode.FileSystem) package. It provides a command line interface for file handling along with some other useful commands. After the installation, you can run the following command to see the usage of SniperCode.FileSystem.Cli:
40+
41+
```bash
42+
sfs
43+
```
44+
45+
This command will show the usage of SniperCode.FileSystem.Cli as shown in picture below.
46+
47+
![SniperCode.FileSystem.Cli](./doc/cli-image.png)
48+
49+
## **References**
50+
51+
All references required while building this package are listed in this document.
52+
53+
### **Articles**
54+
55+
1. [Codeburst.io](https://codeburst.io/build-a-command-line-interface-cli-application-with-node-js-59becec90e28)
56+
2. [Twilio.com](https://www.twilio.com/blog/how-to-build-a-cli-with-node-js)
57+
58+
### **Packages**
59+
60+
1. [SniperCode.FileSystem](https://github.com/Sniper-Code/SniperCode.FileSystem)
61+
2. [Commander](https://www.npmjs.com/package/commander)
62+
3. [Inquirer](https://www.npmjs.com/package/inquirer)
63+
4. [Color](https://www.npmjs.com/package/colors)
64+
5. [Config](https://www.npmjs.com/package/config)
65+
66+
## **ToDo**
67+
68+
1. [ ] Direct execution instead of using [Inquirer](https://www.npmjs.com/package/inquirer) .
69+
2. [ ] Backward compatibility with older terminal.
70+
3. [ ] Custom terminal.
71+
72+
## **Release**
73+
74+
Visit[GitHub Release](https://github.com/Sniper-Code/SniperCode.FileSystem.Cli/releases) to see the latest release.

commands/command.json.js

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
2+
/**
3+
* @function get_all_Commands
4+
* @description This function returns all the commands available in the package.
5+
* @param {Commands} cmd
6+
* @return {Array[Object]}
7+
*/
8+
export function get_all_Commands(cmd) {
9+
return [
10+
// File Append
11+
{
12+
command: 'apfile',
13+
description: 'append to a file',
14+
action: cmd.Commands.File.Append,
15+
},
16+
// Clear
17+
{
18+
command: 'clear',
19+
description: 'clear the screen',
20+
action: cmd.Commands.Clear
21+
},
22+
// Copy Directory
23+
{
24+
command: 'cpdir',
25+
description: 'copy a directory to another directory',
26+
action: cmd.Commands.Directory.Copy,
27+
},
28+
// File Copy
29+
{
30+
command: 'cpfile',
31+
description: 'copy a file to another file',
32+
action: cmd.Commands.File.Copy,
33+
},
34+
// Exists Directory
35+
{
36+
command: 'exdir',
37+
description: 'Check if a directory exists',
38+
action: cmd.Commands.Directory.Exists,
39+
},
40+
// Exists File
41+
{
42+
command: 'exfile',
43+
description: 'Check if a file exists',
44+
action: cmd.Commands.File.Exists,
45+
},
46+
// Execute Command
47+
{
48+
command: 'exec',
49+
description: 'execute a command',
50+
action: cmd.Commands.Shell,
51+
},
52+
// Ip Address
53+
{
54+
command: 'ip',
55+
description: 'get the ip address',
56+
action: cmd.Commands.Network.IpAddress
57+
},
58+
// Is Directory
59+
{
60+
command: 'isdir',
61+
description: 'check if a path is a directory',
62+
action: cmd.Commands.Directory.Is,
63+
},
64+
// Is File
65+
{
66+
command: 'isfile',
67+
description: 'check if a path is a file',
68+
action: cmd.Commands.File.Is,
69+
},
70+
// Operating System
71+
{
72+
command: 'os',
73+
description: 'get the operating system',
74+
action: cmd.Commands.Operating_System.Name
75+
},
76+
// Directory Create
77+
{
78+
command: 'mkdir',
79+
description: 'create a directory',
80+
action: cmd.Commands.Directory.Create
81+
},
82+
// File Create
83+
{
84+
command: 'mkfile',
85+
description: 'create a file',
86+
action: cmd.Commands.File.Create,
87+
},
88+
// Move directory
89+
{
90+
command: 'mvdir',
91+
description: 'move a directory',
92+
action: cmd.Commands.Directory.Move
93+
},
94+
// File Move
95+
{
96+
command: 'mvfile',
97+
description: 'move a file',
98+
action: cmd.Commands.File.Move,
99+
},
100+
// Name of the directory
101+
{
102+
command: 'nmdir',
103+
description: 'get the name of the directory',
104+
action: cmd.Commands.Directory.Name
105+
},
106+
// Name of the file
107+
{
108+
command: 'nmfile',
109+
description: 'get the name of the file',
110+
action: cmd.Commands.File.Name
111+
},
112+
// Name of file with extension
113+
{
114+
command: 'nmextfile',
115+
description: 'get the name of the file with extension',
116+
action: cmd.Commands.File.With_Extension
117+
},
118+
// Path Directory
119+
{
120+
command: 'pwdir',
121+
description: 'get the path of given directory',
122+
action: cmd.Commands.Directory.Path
123+
},
124+
// Path File
125+
{
126+
command: 'pwfile',
127+
description: 'get the path of given file',
128+
action: cmd.Commands.File.Path
129+
},
130+
// Read File
131+
{
132+
command: 'readfile',
133+
description: 'read a file',
134+
action: cmd.Commands.File.Read,
135+
},
136+
// Rename Directory
137+
{
138+
command: 'rendir',
139+
description: 'rename a directory',
140+
action: cmd.Commands.Directory.Rename
141+
},
142+
// File Rename
143+
{
144+
command: 'renfile',
145+
description: 'rename a file',
146+
action: cmd.Commands.File.Rename,
147+
},
148+
// Directory Delete
149+
{
150+
command: 'rmdir',
151+
description: 'delete a directory',
152+
action: cmd.Commands.Directory.Delete
153+
},
154+
// File Remove
155+
{
156+
command: 'rmfile',
157+
description: 'delete a file',
158+
action: cmd.Commands.File.Delete,
159+
},
160+
// Directory List -> Default
161+
{
162+
command: 'scandir',
163+
description: 'list all the directories in specified path at depth 1',
164+
action: cmd.Commands.Directory.List.Default
165+
},
166+
// Directory List -> Depth
167+
{
168+
command: 'scandird',
169+
description: 'list all the directories till the specified depth',
170+
action: cmd.Commands.Directory.List.Depth
171+
},
172+
// Directory List -> Recursive
173+
{
174+
command: 'scandirr',
175+
description: 'list all the directories recursively',
176+
action: cmd.Commands.Directory.List.Recursive
177+
},
178+
// Search
179+
{
180+
command: 'search',
181+
description: 'search for a file or directory',
182+
action: cmd.Commands.Search
183+
},
184+
// File Size
185+
{
186+
command: 'sizefile',
187+
description: 'get the size of a file',
188+
action: cmd.Commands.File.Size
189+
},
190+
// File Status
191+
{
192+
command: 'statfile',
193+
description: 'get the status of a file',
194+
action: cmd.Commands.File.Stats
195+
},
196+
// File Update
197+
{
198+
command: 'upfile',
199+
description: 'update a file',
200+
action: cmd.Commands.File.Update,
201+
},
202+
]
203+
}

0 commit comments

Comments
 (0)