-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added About, help, Version flags in CLI
- Loading branch information
1 parent
77e7f19
commit 0ff09ee
Showing
5 changed files
with
107 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# Copyright (c) 2021 Garvit Joshi <garvitjoshi9@gmail.com> | ||
|
||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# Copyright (c) 2021 Garvit Joshi <garvitjoshi9@gmail.com> | ||
|
||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,76 @@ | ||
# Copyright (c) 2021 Garvit Joshi <garvitjoshi9@gmail.com> | ||
|
||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
import sys | ||
from os import system, path, name | ||
from time import sleep, ctime | ||
|
||
|
||
def clear_screen(): | ||
system('cls' if name == 'nt' else 'clear') | ||
|
||
|
||
def main(): | ||
argv = sys.argv | ||
args_len = len(argv) | ||
if args_len == 1: | ||
print("Please give a file name to watch") | ||
sys.exit() | ||
elif args_len == 2: | ||
command = "g++ " + argv[1] | ||
else: | ||
command = "g++ " + (" ".join(argv[2:])) | ||
print("Command used for compiling:", command) | ||
try: | ||
timer = ctime(path.getmtime(argv[1])) | ||
except FileNotFoundError: | ||
print("File:", argv[1], "Not Found") | ||
sys.exit() | ||
last_timer = 0 | ||
system(command) | ||
while True: | ||
if last_timer == 0: | ||
last_timer = timer | ||
timer = ctime(path.getmtime(argv[1])) | ||
if timer != last_timer: | ||
clear_screen() | ||
system(command) | ||
last_timer = timer | ||
timer = ctime(path.getmtime(argv[1])) | ||
sleep(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) | ||
# Copyright (c) 2021 Garvit Joshi <garvitjoshi9@gmail.com> | ||
|
||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
import sys | ||
from os import system, path, name | ||
from time import sleep, ctime | ||
import kompiler.constants as C | ||
|
||
|
||
def clear_screen(): | ||
system('cls' if name == 'nt' else 'clear') | ||
|
||
|
||
def version(): | ||
print(C.VERSION) | ||
|
||
|
||
def about(): | ||
print(C.ABOUT) | ||
|
||
|
||
def help(): | ||
print(C.HELP) | ||
|
||
|
||
def main(): | ||
argv = sys.argv | ||
args_len = len(argv) | ||
if args_len == 1: | ||
print("Please give a file name to watch") | ||
help() | ||
sys.exit() | ||
elif args_len == 2: | ||
if argv[1] in ("--version", "-v"): | ||
version() | ||
sys.exit() | ||
elif argv[1] in ("--help", "-h"): | ||
help() | ||
sys.exit() | ||
elif argv[1] in ("--about", "-a"): | ||
about() | ||
sys.exit() | ||
command = "g++ " + argv[1] | ||
else: | ||
command = "g++ " + (" ".join(argv[2:])) | ||
print("Command used for compiling:", command) | ||
try: | ||
timer = ctime(path.getmtime(argv[1])) | ||
except FileNotFoundError: | ||
print("File:", argv[1], "Not Found") | ||
sys.exit() | ||
last_timer = 0 | ||
system(command) | ||
while True: | ||
if last_timer == 0: | ||
last_timer = timer | ||
timer = ctime(path.getmtime(argv[1])) | ||
if timer != last_timer: | ||
clear_screen() | ||
system(command) | ||
last_timer = timer | ||
timer = ctime(path.getmtime(argv[1])) | ||
sleep(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
VERSION_NO = "0.4.0" | ||
|
||
VERSION = "Kompiler: v"+VERSION_NO | ||
|
||
ABOUT = """ | ||
Kompiler: A package for auto compiling C++ files as soon as they are saved.\n | ||
Source Code: https://github.com/garvit-joshi/kompiler/ | ||
pip: https://pypi.org/project/kompiler/ | ||
Made by Garvit Joshi https://github.com/garvit-joshi | ||
""" | ||
|
||
HELP = """ | ||
Usage: kompiler [File.cpp] [COMMAND...] | ||
eg: | ||
❯ kompiler hello.cpp | ||
Command used for compiling: g++ hello.cpp\n | ||
❯ kompiler hello.cpp -std=c++11 -O2 -Wall hello.cpp -o hello | ||
Command used for compiling: g++ -std=c++11 -O2 -Wall hello.cpp -o hello\n | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
requires = [ | ||
"setuptools>=56", | ||
"wheel>=0.36", | ||
"pip>=21" | ||
"pip>=21.1.2" | ||
] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters