Package: new-sefile
Sefile CLISefile CLI is a personal project created by Faisal Ramadhan or myself. This project was built using the Python programming language. At the time of its creation, this CLI was only useful for finding the desired file according to the initial directory, but over time I started adding several new commands, such as Create, Read, Write and Delete. All of these commands have their own purpose and function.This CLI tool has available inhttps://pypi.org/you can access it inhttps://pypi.org/project/new-sefile/from there you can know how this CLI tool was made.To install this CLI tool, you can simply type on your terminal or CMD:python3-mpipinstallnew-sefileTo upgrade the CLI tool to the newest version, you can simply type on your terminal or CMD:python3-mpipinstall--upgradenew-sefile[!WARNING]
To execute this package as a CLI tool, you must first registred the python $PATH for this package. So go check out your directory that save all of your python package. All operating system, has a different path where the python package saved, so search for it in Google first.For Linux OS & Mac OS:sudonano~/.bashrcAnd now you are in .bashrc file, then add new line code, like:exportPATH="/home/(user)/(path)/bin:$PATHRemember the (path) is different for every linux users, so from me is that you must search first where all you python package was saved. Then you can add new PATH into your python PATH, like above.There are some different file names, that run executable dotfiles (.file) is your system, such as:.bashrc.profile.bash_profile.zprofile.zlogin.bash_loginSo in my opinion, that you must search where the executable file that execute your python package.For Windows OS:[!NOTE]
For this operating system, i know you can do it by yourself, right?RequirementsEach project must have additional modules or packages for ease of project creation. I myself use a lot of packages to make this CLI. The modules or packages list that I use is:typing[!NOTE]
if you want more information about this library, seehttps://docs.python.org/3/library/typing.htmlfnmatch[!NOTE]
if you want more information about this library, seehttps://docs.python.org/3/library/fnmatch.htmllogging[!NOTE]
if you want more information about this library, seehttps://docs.python.org/3/howto/logging.htmlosInfo: > if you want more information about this library, seehttps://docs.python.org/3/library/os.htmlpathlib[!NOTE]
if you want more information about this library, seehttps://docs.python.org/3/library/pathlib.htmltyperInstallation:python-mpipinstall"typer[all]"[!NOTE]
if you want more information about this library, seehttps://typer.tiangolo.com/tutorial/first-steps/rich[!WARNING]
If you dopip install "typer[all]"before, then you don't have to install the rich module.Installation:python-mpipinstallrich[!NOTE]
If you want more information about this library, seehttps://rich.readthedocs.io/en/stable/introduction.htmltermcolorInstallation:python-mpipinstalltermcolor[!NOTE]
if you want more information about this library, seehttps://github.com/termcolor/termcolornpyscreenInstallation:python-mpipinstallnpyscreen[!NOTE]
if you want more information about this library, seehttps://npyscreen.readthedocs.io/introduction.htmlascii-magicInstallation:python-mpipinstallascii-magic[!NOTE]
if you want more information about this library, seehttps://pypi.org/project/ascii-magic/coloramaInstallation:python-mpipinstallcolorama[!NOTE]
if you want more information about this library, seehttps://pypi.org/project/colorama/PillowInstallation:python-mpipinstallPillow[!NOTE]
if you want more information about this library, seehttps://pillow.readthedocs.io/en/stable/artInstallation:python-mpipinstallart[!NOTE]
if you want more information about this library, seehttps://www.ascii-art.site/How to use itIt's quite easy, you just need to enter the commandsefile --help, then you get the output like this:[!NOTE]
if you want more information about this library, seehttps://www.ascii-art.site/How to use itIt's quite easy, you just need to enter the commandpython -m sefile --help, then you get the output like this:How to show CLI version and information?sefile--versionorsefile-vHow to find a file?sefilefind<filename>or[!NOTE]
You can specify the initial directory path to find the file you want.sefilefind<filename><path>At first I created this based only on the filename, but eventually I added new flag options, namely --startswith and --endswith.--startswithflag is useful for searching files with your own custom prefix. Usage examples:[!NOTE]--startswithflag has been set asis_eager=True, meaning this parameter will be executed and the main parameter will be overridden. Also, you need to input from what(path)you want to search file startswith(prefix).sefilefind--startswithmainWhen you do this, the system will automatically look for files with a certain (in this casemain) prefix from each directory or sub-directory that matches the initial directory.--endswithflag is useful for searching files with your own custome prefix. Usage examples:[!NOTE]--endswithflag has been set asis_eager=True, meaning this parameter will be executed and the main parameter will be overridden.sefilefind--endswith.pyThis flag has same functional as--startswithflag, but search file by the end name of the file that match with your custome prefix. Also, you need to input from what(path)you want to search file endswith(prefix).[!NOTE]--lazyflag has been asis_eager=True, meaning this parameter will be executed and the main parameter will be overridden.sefilefind--lazyThis flag can be use if you to lazy to input CLI command. You only need to enter a special custom query, namelyfind  from. This custom query has same functionality assefile findcommand.There are several input command you can do:find(filename)from(path)for Linux OS: find main.py from /home/(user)/Documentsfor Windows OS: find main.py from C:\Directory\SubDirectoryfind from(path)startswith(prefix)for Linux OS: find file from /home/(user)/Documents startswith mainfor Windows OS: find file from C:\Directory\SubDirectory startswith mainfind from(path)like(prefix)for Linux OS: find file from /home/(user)/Documents like testfor Windows OS: find file from C:\Directory\SubDirectory like testNOTE: You can also do'quit'or'exit'custom query in input field. This situation will needed if you want tocancelthe find activity. So it makes more flexible for you to usefindcommandHow to create a file?sefilecreate<filename>[!NOTE]
Default directory set as/home/usernameorsefilecreate<filename><path>The system will automatically create a file with a certain file type (according to the type you add at the end of the file) in the directory you enter.[!NOTE]
In newest update, there's one Options called--project. This useful for you if you too lazy for creating simple project.Rememberthis Options, will createPython, Javascript, or Goproject, depends on your choice.To run--projectOptions, you just simply write it in your terminal like this below:sefilecreate--projectAnd you got this little thing:What's project you want to create?>  🐍 Easy Python👑 The king of Javascript🐼 Cute Go❌ Nah, i'mgoodWhat'sthenameofthe🐍EasyPythonproject?my_api_project
Wheredoyouwanttosavethismy_api_project?/home/users/DocumentsNOTE: You can do'quit'or'exit'command in input field. This command so useful if you are in the situation where you don't wanna input anything, or you do wrong input name in project name, or project directory, or when you choose the wrong project what you want to make.In the newest update, i add another functionality for this create command. It's--writeoptions. To using it, just simply type:sefilecreate--writeIt's automatically displaying Code Editor Interface in your terminal.[!NOTE]
you need specifiy the Filename and Path first, before you do code or creating text.So this write command, doesn't need ARGS at all, you just input command in your terminal above, and you can do code in your terminal.INFORMATION:So if you notice, theres is'EXIT'button and'SAVE'button right? the functionality of these 2(two) button are same as'EXIT'button and'SAVE'button in your code editor.You can exit whatever you want, but you can't save the code if you not input value in'Filename'and'Folder Path'. So be careful when you use this.How to read a file?sefileread<filename><path>or--formatflag is especially useful for reading files of a certain type. Default file typer set astextor.txt. Example of the output:Example 1:Do this command in your terminal:sefileread<filename><path>--formatpython--indent--themeone-darkAnd you get a result like this in your terminal (NOTE: This is just example)╭──────────────────────────────────────────────────────────experiments.py───────────────────────────────────────────────────────────╮│1# ./learn_class/experiments.py                                                                                                 ││2││3importgeocoder││4││5fromdataclassesimportdataclass││6fromfuzzywuzzyimportfuzz,process││7fromgeopy.geocodersimportNominatim││8fromgeonamescacheimportGeonamesCache││9fromtimezonefinderimportTimezoneFinder││10││11@dataclass││12classExperiment:││13│││14│@staticmethod││15│deffirst_experiment()->None:││16││"""                                                                                                                    ││   17 │   │   ------------                                                                                                           ││   18 │   │   |Definition|                                                                                                           ││   19 │   │   ------------                                                                                                           ││   20 │   │                                                                                                                          ││   21 │   │   This function is useful for tracking the current location by using the user's IP address.                              ││   22 │   │   """││23││locator=Nominatim(user_agent="My App")││24││my_location=geocoder.ip('me')││25││latitude=my_location.geojson['features'][0]['properties']['lat']││26││longtitude=my_location.geojson['features'][0]['properties']['lng']││27││││28││location=locator.reverse(f"{latitude},{longtitude}")││29││print(f"Your current IP location:{location}")││30│││31│@staticmethod││32│defsecond_experiment(city:str)->None:││33││"""                                                                                                                    ││   34 │   │   ------------                                                                                                           ││   35 │   │   |Definition|                                                                                                           ││   36 │   │   ------------                                                                                                           ││   37 │   │                                                                                                                          ││   38 │   │   This function is useful for tracking the current location by simply entering the city inputted by the user.            ││   39 │   │   """││40││geolocator=Nominatim(user_agent='My App')││41││location=geolocator.geocode(city)││42││latitude=location.latitude││43││longitude=location.longitude││44││print(f"City name:{city}\nLatitude:{latitude}\nLongitude:{longitude}\n")││45││││46││timezone=TimezoneFinder()││47││timezone_of_the_city=timezone.timezone_at(lat=latitude,lng=longitude)││48││print(f"Timezone of{city}:{timezone_of_the_city}")││49││││50││geonamescache_obj=GeonamesCache()││51││cities=[city['name']forcityingeonamescache_obj.get_cities().values()]││52││print(cities[:100])││53││54││55│╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯[!NOTE]
this is just an example, the output will vary depending on the type of file you entered and the program in the file you enteredIf you want to add indent for read code, you just simply add--indentor-i, you can just type like:sefileread<filename><path>--formatpython--indentIf you want to change theme also want to add indent, you can just type like:sefileread<filename><path>--formatpython--indent--thememonokaiAll of theme that i add are:one-dark 		(dark theme)monokai 		(dark theme)dracula 		(dark theme)material 		(dark theme)gruvbox-light (light theme)lightbulb 	(light theme)Or you can just type,sefileread--helpFor to know what all themes that available.How to remove a file?sefileremove<path><filename>So you must input the path directory first then file that inside the directory.In other hand, this command also has many options. The first one is--startswithor you just simpy type-s. To implement this command, you can type like:sefileremove<path>--startswith<prefix>[!NOTE]
For--startswithand--endswithoptions, it must required a prefix that related into this two options. For example, if you want to search file startswith something (depends on what value you inputed), you must use--startswith, but if you want to search file format endswith, let's say.py, then you must use--endswithoptions.The second options is--endswithor you just simply type-e. To implement this command, you can type like:sefileremove<path>--endswith<prefix>The last one is--subfolderor you just simply type-sf. This options has functionality to remove sub folder and it's content from path directory target. To implement this command, you can type like:sefileremove<path>--subfolderKeep in mindThis program is only useful forfind, create, read, write and remove. Apart from that, I have nothing to add. I personally will only focus on the main command program, because there are still many things that can be updated in the future.