Skip to content

Commit 2a5b200

Browse files
authored
Added Support for C
Now you can generate C projects as well from FnC
1 parent d8314c9 commit 2a5b200

11 files changed

+248
-45
lines changed

CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
1. Added support for dynamically generating AuthorName, as one of the parameters.
1313
2. Improved the Help menu syntax with single line of code.
1414

15-
## v20211222
15+
## v20211223
1616
1. Changed the Default path from APPDATA to LocalAppData
1717
2. Made it easier to Add support for new languages for the developer (Currently - only Bat is supported)
1818
3. The user can easily handle the template of the files to generate/Folder Structure.
1919
4. Added support for choosing AuthorName while generating Template.
20-
5. Added support for choosing the project location
20+
5. Added support for choosing the project location
21+
6. Added support for C projects generation
22+
7. Fixed Bug with 'Fnc /?'

Demo_FnC.bat

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ for /f %%a in ('copy /Z "%~dpf0" nul') do set "BS=%%a"
88

99
:Main
1010
Set /P "_FileName=Type FileName to Generate:"
11-
Set /P "_Lang=Programming Language (Bat, Py, C, ahk): (only Bat Supported yet)"
12-
Set /P "_Author=Author of Project:"
13-
Set /P "_ProjectPath=Location of Project (e.g: D:\Projects):"
1411
If Not Defined _FileName (Goto :Main)
12+
Set /P "_Lang=Programming Language (Bat, C): "
1513
If Not Defined _Lang (Goto :Main)
14+
Set /P "_Author=Author of Project:"
15+
Set /P "_ProjectPath=Location of Project (e.g: D:\Projects):"
16+
1617
Echo. Creating File...
1718
Echo. The Process of File Generation might be Slow in Win 10, Because of Defender.
1819
Start /b Call FnC "%_FileName%" "%_Lang%" "%_Author%" "%_ProjectPath%"

Files/Bat/FolderStructure.bat

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
MD "%_Project_Location%\%_Name%"
22
MD "%_Project_Location%\%_Name%\bin"
3+
MD "%_Project_Location%\%_Name%\Demo"
34
MD "%_Project_Location%\%_Name%\Src"
45
MD "%_Project_Location%\%_Name%\Src\Files"
56
echo.>"%_Project_Location%\%_Name%\README.md"

Files/Bat/Project.bat

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ For %%A in (
33
"Setlocal EnableDelayedExpansion"
44
""
55
"Set _path^=%%LocalAppdata%%\%_Name%"
6-
"Set path=%%path%%;%%_path%%;%%cd%%;%%cd%%\Files;"
6+
"Set path=%%path%%;%%_path%%;%%~dp0;%%~dp0Files;%%cd%%;%%cd%%\Files;"
77
"Cd Files ^>nul 2^>nul"
88
"If Not exist ^"%%_path%%^" ^(Md ^"%%_path%%^"^)"
99
""
@@ -43,8 +43,14 @@ For %%A in (
4343
""
4444
""
4545
"REM Checking for various parameters of the function..."
46-
"for %%%%A in ^(^"/\/\^" ^"--help^" ^"-h^" ^"-\/\^" ^"-help^"^) do ^(if /i ^"%%%%A^" ^=^= ^"%%~1^" ^(goto :help^)^)"
47-
"If /i ^"%%~1^" ^=^= ^"ver^" ^(Echo.%%_ver%%^&Goto :End^)"
46+
"If /i ^"%%~1^" ^=^= ^"--help^" ^(goto :help^)"
47+
"If /i ^"%%~1^" ^=^= ^"-h^" ^(goto :help^)"
48+
"If /i ^"%%~1^" ^=^= ^"-help^" ^(goto :help^)"
49+
"If /i ^"%%~1^" ^=^= ^"/\/\^" ^(goto :help^)"
50+
"If /i ^"%%~1^" ^=^= ^"-\/\^" ^(goto :help^)"
51+
"If /i ^"%%~1^" ^=^= ^"^" ^(goto :help^)"
52+
""
53+
"If /i ^"%%~1^" ^=^= ^"ver^" ^(Echo.%%_ver%%^&Goto :End^)"
4854
"If /i ^"%%~1^" ^=^= ^"^" ^(goto :help^)"
4955
""
5056
"If /i ^"%%~2^" ^=^= ^"^" ^(goto :help^)"

Files/C/Changelog.bat

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
For %%A in (
3+
"# Project: !_Name! - by !_Author!"
4+
"## v1.0"
5+
"1. "
6+
"2. "
7+
""
8+
""
9+
"## v2.0"
10+
"1. "
11+
"2. "
12+
""
13+
""
14+
"## v3.0"
15+
"1. "
16+
"2. "
17+
""
18+
""
19+
"www.batch-man.com"
20+
) do (
21+
REM Fixing a Bug with Generation of '?' symbol in files via script...
22+
Set "_Line=%%~A"
23+
if Defined _Line (Set "_Line=!_Line:\/\=?!")
24+
Echo.!_Line!>>"CHANGELOG.md"
25+
)

Files/C/FolderStructure.bat

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MD "%_Project_Location%\%_Name%"
2+
MD "%_Project_Location%\%_Name%\bin"
3+
MD "%_Project_Location%\%_Name%\Demo"
4+
MD "%_Project_Location%\%_Name%\Src"
5+
MD "%_Project_Location%\%_Name%\Src\Files"
6+
echo.>"%_Project_Location%\%_Name%\README.md"
7+
echo.>"%_Project_Location%\%_Name%\CHANGELOG.md"

Files/C/Project.bat

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
For %%A in (
2+
""
3+
"/_/\_ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY"
4+
" KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE"
5+
" WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE"
6+
" AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT"
7+
" HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,"
8+
" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"
9+
" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER"
10+
" DEALINGS IN THE SOFTWARE. _/\_/"
11+
""
12+
"#include <stdio.h>"
13+
"#include <string.h>"
14+
"#include <stdlib.h>"
15+
""
16+
"#ifdef WIN32"
17+
"#include <windows.h>"
18+
"#else"
19+
"#include <unistd.h>"
20+
"#endif"
21+
""
22+
"char ver[] ^= ^"1.0^";"
23+
"char name[] ^= ^"!_Name!^";"
24+
""
25+
"/_/\_ This program is distributed under the following license: (SELECT A LICENSE)"
26+
""
27+
" ================================================================================"
28+
" Apache License 2.0 - https://opensource.org/licenses/Apache-2.0"
29+
" BSD 3-Clause 'New' or 'Revised' license - https://opensource.org/licenses/BSD-3-Clause"
30+
" BSD 2-Clause 'Simplified' or 'FreeBSD' license - https://opensource.org/licenses/BSD-2-Clause"
31+
" GNU General Public License (GPL) - https://opensource.org/licenses/gpl-license"
32+
" GNU Library or 'Lesser' General Public License (LGPL) - https://opensource.org/licenses/lgpl-license"
33+
" MIT license - https://opensource.org/licenses/MIT"
34+
" Mozilla Public License 2.0 - https://opensource.org/licenses/MPL-2.0"
35+
" Common Development and Distribution License - https://opensource.org/licenses/CDDL-1.0"
36+
" Eclipse Public License version 2.0 - https://opensource.org/licenses/EPL-2.0"
37+
" ================================================================================"
38+
""
39+
""
40+
" ================= ABOUT THE PROGRAM ================="
41+
" This program is created by !_Author! at '!date! - !time:~0,-6!'"
42+
" This program can _______________________________________________________"
43+
" Use '/\/\' for getting help for this."
44+
" For More Visit: www.batch-man.com _/\_/"
45+
""
46+
""
47+
"void Help^(^)"
48+
"{"
49+
" printf^( _\/_\n"
50+
" This function will _______________________________________________________ \n"
51+
" It will help in __________________________________________________________ \n"
52+
" CREDITS: %%s %%s by !_Author! \n"
53+
"\n"
54+
" Syntax: call %%s [] [] [] [] [] [] [] [] [] \n"
55+
" Syntax: call %%s [help , /\/\ , -h , -help] \n"
56+
" Syntax: call %%s ver \n"
57+
"\n"
58+
"Where:- \n"
59+
"\n"
60+
" ver : Displays version of program \n"
61+
" help : Displays help for the program \n"
62+
" [] : __________________________________________________________ \n"
63+
" [] : __________________________________________________________ \n"
64+
"\n"
65+
" Example: %%s [] [] [] [] [] [] [] [] [] \n"
66+
"\n"
67+
" Now, you can __________________________________________________________ \n"
68+
" _________________. \n"
69+
"\n"
70+
" Libraries required for this project: \n"
71+
" _________________ \n"
72+
" _\/_, name, ver, name, name, name, name, name, name^);"
73+
" return;"
74+
"}"
75+
""
76+
""
77+
"int main^(int argc, char _/\_argv[]^)"
78+
"{"
79+
" if ^(argc ^< 2 ^|^| not^(strcmp^(argv[1]^, ^"--help^"^)^) ^|^| not^(strcmp^(argv[1]^, ^"-h^"^)^) ^|^| not^(strcmp^(argv[1]^, ^"/\/\^"^)^)^)"
80+
" {"
81+
" Help^(^);"
82+
" return EXIT_SUCCESS;"
83+
" }"
84+
""
85+
" if ^(not^(strcmp^(argv[1], _\/_ver_\/_^)^)^)"
86+
" {"
87+
" printf(_\/_%%s_\/_,ver);"
88+
" return EXIT_SUCCESS;"
89+
" }"
90+
""
91+
" // Main program"
92+
""
93+
""
94+
" return EXIT_SUCCESS;"
95+
""
96+
"}"
97+
""
98+
) do (
99+
100+
REM Fixing a Bug with Generation of '?' and '*' symbol in files via script...
101+
Set "_Line=%%~A"
102+
if Defined _Line (
103+
Set "_Line=!_Line:\/\=?!"
104+
Set "_Line=!_Line:_/\_=*!"
105+
Set "_Line=!_Line:_\/_="!"
106+
)
107+
Echo.!_Line!>>"!_Name!.C"
108+
)

Files/C/Readme.bat

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
3+
For %%A in (
4+
"# !_Name! - by !_Author!"
5+
"## Description"
6+
"This program can ___________________________________________________"
7+
""
8+
"Author: !_Author!"
9+
""
10+
"## Usage"
11+
"Call !_Name! [syntax]"
12+
""
13+
"Where:"
14+
""
15+
"- `ver` : Displays version of program"
16+
"- `help` : Displays help for the program"
17+
"- `_________` : ___________________________________________________"
18+
""
19+
"Example: "
20+
"`call !_Name! ____________`"
21+
""
22+
""
23+
""
24+
"www.batch-man.com"
25+
) do (
26+
REM Fixing a Bug with Generation of '?' symbol in files via script...
27+
Set "_Line=%%~A"
28+
if Defined _Line (Set "_Line=!_Line:\/\=?!")
29+
Echo.!_Line!>>"README.md"
30+
)

Files/GenerateCProject.bat

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Pushd "%_Project_Location%\%_Name%\Src" >nul 2>nul
2+
If Exist "%_Name%.C" (Echo. File Already Exists! Can't Overwrite!&&Goto :EOF)
3+
4+
REM Generating the Main Project File...
5+
Call "%_FnC_Location%\Files\%_Lang%\Project.bat"
6+
Echo. Generated "..\%_Name%\Src\!_Name!.C" ...
7+
Echo.
8+
Popd
9+
10+
11+
Pushd "%_Project_Location%\%_Name%"
12+
Echo. Generating README.md File...
13+
14+
REM Generating the README.md File...
15+
Call "%_FnC_Location%\Files\%_Lang%\README.bat"
16+
Echo. Generated "..\%_Name%\README.md" ...
17+
Echo.
18+
19+
Echo. Generating CHANGELOG.md File...
20+
21+
REM Generating the CHANGELOG.md File...
22+
Call "%_FnC_Location%\Files\%_Lang%\CHANGELOG.bat"
23+
Echo. Generated "..\%_Name%\CHANGELOG.md" ...
24+
Echo.
25+
26+
Popd

FnC.bat

+22-25
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ REM see www.gnu.org/licenses
2121

2222

2323
REM ================= ABOUT THE PROGRAM =================
24-
REM This program was created by Kvc at 'Mon 11/02/2020 - 19:04'
25-
REM This program can generate a skeleton for you to start your projects easy!
26-
REM For More, Visit: www.batch-man.com
24+
REM This program is Created by Kvc at 'Mon 11/02/2020 - 19:04'
25+
REM This program can Generate a Skeleton for you to start your projects easy!
26+
REM For More Visit: www.batch-man.com
2727

2828

2929
REM Setting version information...
30-
Set _ver=20211222
30+
Set _ver=20220129
3131

32-
REM Checking for various parameters sent to the function...
33-
for %%A in ("/?" "-h" "-help" "--help" "help" "") do (if /i "%~1"=="%%~A" (goto :help))
32+
REM Checking for various parameters of the function...
33+
If /i "%~1" == "/?" (Goto :Help)
34+
If /i "%~1" == "" (Goto :Help)
35+
If /i "%~2" == "" (Goto :Help)
36+
37+
for %%A in ("-h" "-help" "--help" "help") do (if /i "%~1"=="%%~A" (goto :help))
3438
If /i "%~1" == "ver" (Echo.%_ver%&Goto :End)
3539

3640
REM Saving parameters to variables...
@@ -48,20 +52,13 @@ Set _FnC_Location=%_FnC_Location:~0,-1%
4852
if /i "!_Author!" == "" (set "_Author=[AUTHOR]")
4953
if /i "!_Project_Location!" == "" (set "_Project_Location=%_FnC_Location%")
5054

51-
Set _Valid=0
52-
REM Temporary line to tell user about the supported languages...
53-
IF /i "!_Lang!" NEQ "Bat" (Echo. NOT SUPPORTED YET!&&Goto :End)
54-
For %%A in ("Bat" "C" "Py" "ahk") do (
55-
If /i "%%~A" == "!_Lang!" (
56-
Set _Valid=1
57-
IF NOT EXIST "!_Project_Location!\!_Name!" (
58-
REM Create a Folder Structure as well...
59-
Call "!_FnC_Location!\Files\!_Lang!\FolderStructure.bat"
60-
)
61-
Call "!_FnC_Location!\Files\Generate%%~AProject.bat"
62-
)
63-
)
64-
If %_Valid% == 0 (Echo."Invalid Language!")
55+
If NOT Exist "%_FnC_Location%\Files\%_Lang%" (Echo.Language not supported! Try 'FnC /?'&&Goto :End)
56+
57+
IF NOT EXIST "!_Project_Location!\!_Name!" (
58+
REM Create a Folder Structure as well...
59+
Call "!_FnC_Location!\Files\!_Lang!\FolderStructure.bat"
60+
)
61+
Call "!_FnC_Location!\Files\Generate!_Lang!Project.bat"
6562
Goto :End
6663

6764
:End
@@ -71,7 +68,7 @@ Goto :EOF
7168
Echo.
7269
Echo. This function will generate the backbone batch code structure of the new
7370
Echo. function in a file ^(in the same folder^). - aka Template.
74-
echo. It will help you to quickly start with your projects, without too much
71+
echo. It will help you in quickly starting with your projects, without too much
7572
Echo. thoughts about the basic - repeating things.
7673
echo.
7774
echo. Syntax: call FnC ^<Name^> ^<Language^> [Author] [ProjectLocation]
@@ -80,12 +77,12 @@ echo. Syntax: call FnC ver
8077
echo.
8178
echo. Where:-
8279
echo.
83-
echo. ver : Displays the version of program
84-
echo. help : Displays the help for the program
80+
echo. ver : Displays version of program
81+
echo. help : Displays help for the program
8582
echo. Name : Name of the file to generate ^(Program will add .bat extension^)
86-
echo. Language : Bat, Py, C, Ahk ^(One of these Coding Languages^)
83+
echo. Language : Bat, C ^(One of these Coding Languages^)
8784
echo. Author : Author of the file to generate ^(optional^)
88-
echo. ProjectLocation : Location of the project ^(optional^)
85+
echo. ProjectLocation : Location of the Project ^(optional^)
8986
Echo.
9087
Echo. Example: call FnC FnC Bat Kvc "D:\Projects\FnC"
9188
Echo. Example: call FnC Table-Function C anic17 "D:\Projects\Table-Function"

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
# FnC Function
2-
## Description
2+
**Description:**
33
This program can generate a skeleton for you to start your projects easy! This will generate the folder structure of the project and you will find the generated file in the ProjectName\src\ folder.
44

55
It also generates basic README.md and CHANGELOG.md for easily intigrate the projects on GitHub.
66

7-
Author: Kvc
7+
AUTHOR: Kvc
88

9-
## Usage
9+
# USAGE
1010

11-
`call FnC [Name | help , /? , -h , -help | ver] [Language] [Author] [ProjectLocation]`
11+
<code>Call FnC [Name | help , /? , -h , -help | ver] [Language] [Author] [ProjectLocation]</code>
1212

13-
Where:
13+
Where:-
1414

1515
ver : Displays version of program
1616
help : Displays help for the program
1717
Name : Name of the file to generate [program will add .bat extension]
18-
Language : Bat, Py, C, Ahk ^(One of these Coding Languages^)
18+
Language : Bat, C ^(One of these Coding Languages^)
1919
Author : Author of the file to generate ^(optional^)
2020
ProjectLocation : Location of the Project ^(optional^)
2121

22-
Example: `call FnC FnC Bat Kvc "D:\Projects\FnC" `
23-
Example: `call FnC Table-Function C anic17 "D:\Projects\Table-Function" `
22+
Example: call FnC FnC Bat Kvc "D:\Projects\FnC"
23+
Example: call FnC Table-Function C anic17 "D:\Projects\Table-Function"
2424

25-
Now, you can start working on your projects quickly and with less hassle.
26-
So, jump start your awesome scripts.
25+
Now, you can start working on your projects quickly and with less hassle.
26+
So, jump start your awesome scripts.
2727

28-
[#batch-man]
29-
Article- https://batch-man.com/batch-template-generator-fnc/
28+
Article- https://batch-man.com/batch-template-generator-fnc/
29+
#batch-man

0 commit comments

Comments
 (0)