Skip to content

Commit 42c2928

Browse files
committed
[ISSUE#5] - minify added
Signed-off-by: ashish <[email protected]>
1 parent 07d9495 commit 42c2928

File tree

4 files changed

+66
-35
lines changed

4 files changed

+66
-35
lines changed

docs/cdt/commands/hash.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: hash
33
title: Hash
4-
sidebar_label: Hash Command
4+
sidebar_label: Hash
55
---
66
### `cdt hash [STRING]`
77

@@ -31,19 +31,31 @@ $ cdt hash -s 'abcde'
3131
```
3232
> Note: ***-s flag*** will override the string passed with argument
3333
34-
### Finding hash of a given string for any type e.g. MD5
34+
### Finding hash for any type
3535
------
36+
> We can use -t or --type flag to pass Type
37+
> Supported type: SHA1(default), MD5, SHA256, SHA512, RMD160 or RIPEMD160
3638
``` bash
3739
$ cdt hash -t md5 'abcde'
3840
✔ success [MD5] ab56b4d92b40713acc5af89985d4b786
3941
```
4042

41-
> Note: Possible types SHA1(default), MD5, SHA256, SHA512, RMD160 or RIPEMD160
42-
43-
### Finding hash of a given file for any type e.g. MD5
43+
### Finding hash for a File
4444
------
4545
``` bash
4646
$ cdt hash -t md5 -f ./file.txt
4747
✔ success [MD5] ab56b4d92b40713acc5af89985d4b786
4848
```
4949

50+
### Writing output to a file
51+
------
52+
> We can use -o or --output flag to pass output file path
53+
54+
``` bash
55+
$ cdt hash -t sha512 -f ./file.txt -o ./out.txt
56+
ℹ info reading file: ./file.txt
57+
✔ success [SHA512] 4493b97b4a0d21fc561070c48d4a62a9bfbeb78c5d9b3c59abf6d41f70da2e9bd45af63d8c62812cf41e50e352ec41b4f407f71d5778b575c503b70081e7a151
58+
ℹ info Could not find file: ./out.txt, creating new one
59+
✔ success output written to file: ./out.txt
60+
```
61+

docs/cdt/commands/minify.md

+47-28
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,68 @@
11
---
2-
id: hash
3-
title: Hash
4-
sidebar_label: Hash Command
2+
id: minify
3+
title: Minify
4+
sidebar_label: Minify
55
---
6-
### `cdt hash [STRING]`
6+
### `cdt minify [FILE]`
77

8-
Hashing functionality for a string/file
8+
Minify functionality for a string/file
99

1010
``` bash
1111
USAGE
12-
$ cdt hash [STRING]
12+
$ cdt minify [FILE]
1313

1414
OPTIONS
15-
-f, --file=file file to be hashed
16-
-h, --help show CLI help
17-
-s, --string=string string to be hashed
18-
-t, --type=type type of hash [SHA1(default), MD5, SHA256, SHA512, RMD160 or RIPEMD160]
15+
-f, --file=file file to be minified
16+
-h, --help show CLI help
17+
-o, --outputFile=outputFile output file path
18+
19+
-t, --type=type type of file to be minified, it will try to find type
20+
with extension supported: JS, HTML/HTM, CSS
21+
1922
```
20-
### Finding hash of a given string for default type ( SHA1 )
23+
### Minifying a file
2124
------
25+
> ( supported type: JS, HTML/HTM, CSS )
2226
``` bash
23-
$ cdt hash 'abcde'
24-
✔ success [SHA1] 03de6c570bfe24bfc328ccd7ca46b76eadaf4334
27+
$ cdt minify test.js
28+
ℹ info reading file: test.js
29+
ℹ info file type: JS
30+
✔ file: undefined minified
31+
✔ success minified output:
32+
console.log("lorem ipsum");let x=10;x<10?console.log("x is less than: "+x):x>10?console.log("x is more than: "+x):console.log("x is equals to: "+x);
2533
```
26-
* we can also use ***-s flag***
27-
34+
* we can also use ***-f flag to pass file path***
2835
``` bash
29-
$ cdt hash -s 'abcde'
30-
✔ success [SHA1] 03de6c570bfe24bfc328ccd7ca46b76eadaf4334
36+
$ cdt minify -f test.js
37+
ℹ info reading file: test.js
38+
ℹ info file type: JS
39+
✔ file: undefined minified
40+
✔ success minified output:
41+
console.log("lorem ipsum");let x=10;x<10?console.log("x is less than: "+x):x>10?console.log("x is more than: "+x):console.log("x is equals to: "+x);
3142
```
32-
> Note: ***-s flag*** will override the string passed with argument
43+
> Note: ***-f flag*** will override the string file path passed with argument
3344
34-
### Finding hash of a given string for any type e.g. MD5
45+
### Specifying file type
3546
------
47+
> We can use -t or --type flag for passing type e.g. JS
3648
``` bash
37-
$ cdt hash -t md5 'abcde'
38-
✔ success [MD5] ab56b4d92b40713acc5af89985d4b786
49+
$ cdt minify -t js test.js
50+
ℹ info reading file: test.js
51+
ℹ info file type: JS
52+
✔ file: undefined minified
53+
✔ success minified output:
54+
console.log("lorem ipsum");let x=10;x<10?console.log("x is less than: "+x):x>10?console.log("x is more than: "+x):console.log("x is equals to: "+x);
3955
```
40-
41-
> Note: Possible types SHA1(default), MD5, SHA256, SHA512, RMD160 or RIPEMD160
42-
43-
### Finding hash of a given file for any type e.g. MD5
56+
> Note: If a invalid type is given ex. if HTML is given and file is JS, then we'll get an error.
57+
58+
### Writing output to a file
4459
------
60+
> We can use -o or --output flag to pass output file path
4561
``` bash
46-
$ cdt hash -t md5 -f ./file.txt
47-
✔ success [MD5] ab56b4d92b40713acc5af89985d4b786
62+
cdt minify -f test.css -o output.css
63+
ℹ info reading file: test.css
64+
ℹ info file type: CSS
65+
✔ file: test/resources/test.css minified
66+
ℹ info Could not find file: output.css, creating new one
67+
✔ success output written to file: output.css
4868
```
49-

docusaurus.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
src: 'img/logo.svg',
2222
},
2323
links: [
24-
{to: 'docs/cdt/installation', label: 'Cdt Documentations', position: 'left'},
24+
{to: 'docs/cdt/installation', label: 'Cdt Docs', position: 'left'},
2525
{to: 'blog', label: 'Blog', position: 'left'},
2626
{
2727
href: 'https://github.com/codingtools/',

sidebars.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313

1414
cdt: {
1515
'Getting Started': ['cdt/installation'],
16-
'Commands': ['cdt/commands/hash'],
16+
'Commands': ['cdt/commands/hash','cdt/commands/minify'],
1717

1818
},
1919
};

0 commit comments

Comments
 (0)