diff --git a/.my_commands.sh b/Mac-OS/.my_commands.sh similarity index 100% rename from .my_commands.sh rename to Mac-OS/.my_commands.sh diff --git a/Mac-OS/README.md b/Mac-OS/README.md new file mode 100644 index 0000000..8c5f9e8 --- /dev/null +++ b/Mac-OS/README.md @@ -0,0 +1,21 @@ +### Install: +```bash +git clone "https://github.com/KalleHallden/ProjectInitializationAutomation.git" +cd ProjectInitializationAutomation +pip install -r requirements.txt +touch .env +Then open the .env file and store your username, password, and desired file destination. Use the provided format at the bottom of this README. +source ~/.my_commands.sh +``` + +### Usage: +```bash +To run the script type in 'create ' +``` + +### Env File Format: +```bash +USERNAME="Username123" +PASSWORD="Password123" +FILEPATH="/path/to/your/project/" +``` diff --git a/create.py b/Mac-OS/create.py similarity index 100% rename from create.py rename to Mac-OS/create.py diff --git a/remove.py b/Mac-OS/remove.py similarity index 100% rename from remove.py rename to Mac-OS/remove.py diff --git a/requirements.txt b/Mac-OS/requirements.txt similarity index 100% rename from requirements.txt rename to Mac-OS/requirements.txt diff --git a/README.md b/README.md index 8c5f9e8..f7cb5f3 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,8 @@ -### Install: -```bash -git clone "https://github.com/KalleHallden/ProjectInitializationAutomation.git" -cd ProjectInitializationAutomation -pip install -r requirements.txt -touch .env -Then open the .env file and store your username, password, and desired file destination. Use the provided format at the bottom of this README. -source ~/.my_commands.sh -``` - -### Usage: -```bash -To run the script type in 'create ' -``` - -### Env File Format: -```bash -USERNAME="Username123" -PASSWORD="Password123" -FILEPATH="/path/to/your/project/" -``` +# Project Initialization Automation +See the respective folder for your operating system. Additional README files can be found there. +## Author +* **Kalle Hallden** - [KalleHallden](https://github.com/KalleHallden) +## Contributors: +* **Red Williams** - [Red-CS](https://github.com/Red-CS) +## Production +Kalle Hallden's Youtube video: [One Day Builds: Automating My Projects With Python](https://www.youtube.com/watch?v=7Y8Ppin12r4) diff --git a/windows_OS/.gitignore b/Windows/.gitignore similarity index 100% rename from windows_OS/.gitignore rename to Windows/.gitignore diff --git a/Windows/README.md b/Windows/README.md new file mode 100644 index 0000000..758db8e --- /dev/null +++ b/Windows/README.md @@ -0,0 +1,159 @@ +# Pre-setup: + +### Create user variables + +#### Manually +``` +Go to +> environment vairables +> Click "New" in User variables (the top one) +> Set name as "PWFA-Path" +> Set value as your workspace path (use double backslash (\\) as path separators) +> Get a token here: https://github.com/settings/tokens/new + > Must have repo, user, and delete_repo permissions +> Set "PWFA-Token" to the given token. +``` +You can, of course, name these whatever you'd like. Just be sure to go through +remote.py, local.py, and remove.py and change that argument. +#### Through CMD +``` +> setx [user variable name] "[user variable token] + +For example: +> setx PWFA-Path "ThisIsMyTokenInQuotes" +``` +Either way, you'll have to reset your pc before using them. +# Setup: +``` +git clone "https://github.com/Red-CS/ProjectInitializationAutomation.git" +cd projectInitializerAutomation +pip install -r requirements.txt + +If you are on Windows, which you probably are, be sure to add the "projectInitializerAutomation\windows_OS" +folder directory to path, instead you will use the files meant for Mac +``` + +# Usage: +## Create +#### General Use +Basically, the core of the command is this: +``` +create [options] +``` +The repository name can now have spaces! Just be sure to put them in quotes: +``` +create "Subscribe to Kalle Hallden" +``` +#### Descriptions +Additonally, it's nice to give you're repository a description, yeah? You can type: +``` +create "Subscribe to Kalle Hallden" -d "Remember to like and comment" +OR +create "Subscribe to Kalle Hallden" --description "Share with your friends!" +``` +#### Private Repositories +Want to set your repo to private? Just add -p or --private +``` +create "Subscribe to Kalle Hallden" -d "Like the video" -p. +> Initializes a Github repository set to private. +``` +Don't include this tag for public repos, those are the default. +#### Local Repositories +Creating a local repository is as simple as typing: +``` +create "My Local Repository" -l +OR +create "My Local Repository" --local +``` +Note that it follows that strict syntax (create [repo name] -l/--local) +### Example +Say I wanted to build a remote repository named "Subscribe to Kalle Hallden" with a description of "Leave a like and comment!" We'll set as public, too. Just type: +``` +create "Subscribe to Kalle Hallden" -d "Leave a like and comment!" +``` +You'll see a message on Command prompt that looks like this: +``` +The following arguments will be passed: + Name: Subscribe to Kalle Hallden + Description: Leave a like and comment! + Publicity: Public + +Is this information correct (y/n)? +``` +Simply type "y" or "Y" and your remote Repository will be instantiated. + +If you want to skip that auto confirmation, just add one of the following to the end of the command: +``` +-y --yes --auto-confirm +``` +I recommend doing this for longer repository names and descriptions. + +### Troubleshooting and Help +If you ever need more info on a tag, type either: +``` +-h --help help() +``` +after a tag. For example: +``` +create -d -h +> Outputs description tag usage +``` +Additionally, just typing +``` +create +OR +create -h / --help / help() +``` +will bring up general usage for all tags and commands. +## Remove +#### General Use +``` +remove +``` +Yes, it's that simple. As of this version, you are can remove just the remote repository. Your passed repository name has to match GitHub's version of it. For example: + +If you called +``` +create "Subscribe To Kalle" +``` +Github would read it as +``` +Subscribe-To-Kalle +``` + +To remove this repostory, simply type: +``` +remove Subscribe-To-Kalle +``` +to see a warning and confirmation message to remove the repository remotely. +#### Other Parameters +Let's say you forget the name of the repository you're trying to delete. Typing: +``` +remote -l +OR +remote --list +``` +shows a numbered list of your repositories. +``` +> remove --list + + 1. Like + 2. Comment + 3. Share + 4. And-Subscribe + + ``` +You can use this to delete repositories by position. For example, say you wanted to delete repository #4, "And-Subscribe". Enter: +``` +> remove -4 + + +Warning! + Executing this command would remove https://github.com/User/And-Subscribe + + +Are you sure you want to delete this repository (y/n)? y +Deleted repository https://github.com/User/And-Subscribe +``` +# Authors +Windows files created by Red Williams (Red-CS)[https://github.com/Red-CS] and sharers of previously commited pull requests. See pull request history for more. \ No newline at end of file diff --git a/Windows/choose.py b/Windows/choose.py new file mode 100644 index 0000000..1db48b1 --- /dev/null +++ b/Windows/choose.py @@ -0,0 +1,259 @@ +import os +import sys + +""" +Author: Red Williams (Red-CS) +Email: red.devcs@gmail.com + +July 18, 2020 +""" + +def choose(): + """Chooses which file, remote.py or local.py, is to be run. + Also parses optional parameters (as definied in the params dict) + for additional options when creating a repoisotry remotely. The + API allows for a multiple arguments, but I've included the most + used options. That is why this is meant to be dynamic: if you + want to add more commands, simply create a new tag in the params + dictionary, add it to the if/else block, add to args if necessary, + and read it in the appropriate file (remote.py or local.py). + """ + + # create: Case where only the create command is called + if len(sys.argv) == 1: + general_usage() + sys.exit(0) + + args = { # Example input: create "My repo name" -d "My repo description" -y + "name" : "", # "My repo name" + "description" : "", # "My repo description" + "publicity" : "Public", # public + "auto_confirm" : False # True + } + args["name"] = str(sys.argv[1]) + + params = { + "help" : ["-h", "--help", "help()"], + "description" : ["-d", "--description"], + "private" : ["-p", "--private"], + "local" : ["-l", "--local"], + "auto_confirm" : ["-y", "--yes", "--auto-confirm"] + } + + for i in range(1, len(sys.argv)): + + # Test for -h, --help, or help() + if str(sys.argv[i]) in params["help"]: + + # create -h / create --help / create help() + if len(sys.argv) == 2: + general_usage() + + # create -d -p -h: User doesn't know how to use -h properly + elif len(sys.argv) > 3: + help_usage() + + # create --description --help: Proper use for optional parameter + else: + + # Retrieve help-requested parameter + op_param = str(sys.argv[len(sys.argv) - i]) + + if op_param in params["description"]: + description_usage() + + elif op_param in params["private"]: + private_usage() + + elif op_param in params["local"]: + local_usage() + + elif op_param in params["auto_confirm"]: + auto_confirm_usage() + + else: + print(f"Unknown Option Error: \"{op_param}\" is not recognized") + sys.exit(1) + + sys.exit(0) + + # Test for -l or --local + elif str(sys.argv[i]) in params["local"]: + + # create -l: Cases where no name is included + if len(sys.argv) == 2: + print("Naming Error: Repository name not included.") + sys.exit(1) + + # create --local "My Repo Name": Cases where local creation is used correctly + elif len(sys.argv) == 3 and i == 2: + os.system("python local.py \"{}\"".format(str(sys.argv[1]))) # Must inlcude quotes + + # create -l help(): Get help on using the local tag + elif len(sys.argv) == 3 and str(sys.argv[i+1]) in params["help"]: + local_usage() + + else: + print("Syntax Error: Type \"create -l help()\" for usage.") + sys.exit(0) + + # Test for -d or --description + elif str(sys.argv[i]) in params["description"]: + + try: + # create -d --private: Cases where description tag is used, but no description included + if not is_tag(tag=str(sys.argv[i+1]), dict=params): + args["description"] = str(sys.argv[i+1]) # If next parameter is a tag, leaves description empty + + except IndexError: + # create --private -d: Cases where description tag is last, where sys.argv[i+1] will raise IndexError + print("Unknown Option Error: A description tag was used but no description was provided.") + sys.exit(1) + + # Test for -p or --private + elif str(sys.argv[i]) in params["private"]: + args["publicity"] = "Private" + + # Test for -y, --yes, or --auto-confirm + elif str(sys.argv[i]) in params["auto_confirm"]: + args["auto_confirm"] = True + + else: + # TODO More tags/optional params for the future. + # That's up to you, creator! + pass + + # Presents confirmation message to user + if not args["auto_confirm"]: + if not confirm_info(args): + sys.exit(0) + + # Execution, baby! + os.system("python remote.py \"{name}\" \"{description}\" {publicity}".format(**args)) + +def general_usage(): + """Shows general usage of the create command, as well as the existence of + the remove command. Shows optional paramters as well. Remember to add to this list + and the corresponding usage function when adding new tags. + """ + print() + print("Usage:") + print(" create [options]\n") + + print("Commands:") + print(" create\t\t\t\tCreate a repository.") + print(" remove\t\t\t\tRemove a repository.") + print() + print("Optional Parameters:") + print(" -h, --help\t\t\t\tPrints general usage or usage of a specific option.") + print(" -d, --description\t\t\tAdd a description to the remote repository.") + print(" -p, --private\t\t\t\tSet remote repository to private.") + print(" -l, --local\t\t\t\tCreate a local repository; does not push to Github.") + print("\t\t\t\t\tUse only a repository name and this parameter.") + print(" -y, --yes, --auto-confirm\t\tAutomatically initialize repository without confirmation message.") + print() + +def help_usage(): + """Shows how to use the help tags.""" + print() + print("Syntax Error: Help tag is used incorrectly.") + print() + print("Usage:") + print(" create -h") + print(" create --help") + print(" create help()") + print() + print(" create [option] -h") + print(" create [option] --help") + print(" create [option] help()") + print() + print("Description:") + print(" Explains usage of the \"create\" command and its options") + print() + +def description_usage(): + """Shows how to use the description tags""" + print() + print("Usage:") + print(" create -d \"[repository description]\"") + print(" create --description \"[repository description]\"") + print() + print(" create -d \"[repository description]\" [option]") + print(" create --description \"[repository description]\" [option]") + print() + print("Description:") + print(" The description tag adds a descripiption to the remote repository.") + print(" NOTE: Multi-word descriptions need to be surrounded by quotation marks (\"\")") + print() + +def private_usage(): + """Shows how to use the private tags""" + print() + print("Usage:") + print(" create -p") + print(" create --private") + print() + print(" create [option] -p") + print(" create [option] --private") + print() + print("Description:") + print(" The private tag sets the remote repository to private, as it is") + print(" defaulted to public.") + print(" NOTE: The local tag must not be included, as local repositories") + print(" cannot be public or private.") + print() + +def local_usage(): + """Shows how to use the local tags""" + print() + print("Usage:") + print(" create -l") + print(" create --local") + print() + print("Description:") + print(" The local tag is used to create a repository locally, not") + print(" pushing to GitHub.") + print(" NOTE: To create a local project, only include the project name") + print(" (in quotation marks if it is multi-word), otherwise you will") + print(" recieve an error.") + print() + +def auto_confirm_usage(): + """Shows how to use to automatic confirm tags""" + print() + print("Usage:") + print(" create -y") + print(" create --yes") + print(" create --auto-confirm") + print() + print(" create [options] -y") + print(" create [options] --yes") + print(" create [options] --auto-confirm") + print() + print("Description:") + print(" The auto-confirmation tag is used to automatically create a remote") + print(" repository without confirming that the details are correct.") + print() + +def confirm_info(dict): + """Confirms if the called arguments are correct. This method only calls when + one of the automatic confirm tags aren't listed. + """ + print() + print("The following arguments will be passed:") + print(" Name: {name}".format(**dict)) + print(" Description: {description}".format(**dict)) + print(" Publicity: {publicity}".format(**dict)) + print() + usr = input("Is this information correct (y/n)? ") + return usr.lower() == "y" + +def is_tag(tag, dict): + """Helper method testing if a passed paramter is a defined tag.""" + for key in dict: + if tag in dict[key]: + return True + return False + +if __name__ == "__main__": + choose() \ No newline at end of file diff --git a/Windows/create.bat b/Windows/create.bat new file mode 100644 index 0000000..cee085f --- /dev/null +++ b/Windows/create.bat @@ -0,0 +1,34 @@ +@echo off +setlocal +cd /d %~dp0 + +rem Author: Red Williams (Red-CS) +rem Email: red.devcs@gmail.com + +rem July 18, 2020 + +rem pyParams variable to contain python script's parameters +rem Helper flag for parameter presence. default to 0/FALSE. +set prmOk=0 + +rem Variable to contain python script name to use. default is remote. +set pyName=choose + +rem Process batch parameters +:getParam + +set pyParams=%pyParams% %1 +set prmOk=1 + +shift +rem After SHIFT, %0 is replaced by %1, %1 replaced by %2, %2 replaced by %3, etc. +if "%~1" neq "" goto getParam + +rem Check python script's parameter presence +if %prmOk% == 0 ( + echo Batch parameter is missing. + goto :eof +) + +python %pyName%.py%pyParams% +:eof \ No newline at end of file diff --git a/Windows/local.py b/Windows/local.py new file mode 100644 index 0000000..013aa42 --- /dev/null +++ b/Windows/local.py @@ -0,0 +1,43 @@ +import os +import sys + +from colorama import init, Fore, Style + +""" +Author: Red Williams (Red-CS) +Email: red.devcs@gmail.com + +July 18, 2020 +""" + +# The world is dark enough, let's add some color! +init() + +# Get repository name +repo_name = str(sys.argv[1]) + +# Set directory +_dir = "{}\\\\{}".format(os.environ.get("PWFA-Path"), repo_name) + +# Create local repository +if not os.path.isdir(_dir): + os.mkdir(_dir) +os.chdir(_dir) + +# Test if git is initialzed +if os.path.isdir(f"{_dir}\\.git"): + usr = input("Git is already initialized. Reinitialize git (y/n)? ") + if not usr.lower() == "y": + sys.exit(0) + +# Initialize git +os.system('git init') +os.system(f'echo # {repo_name} > README.md') +os.system('git add README.md') +os.system('git commit -m "Initial commit"') + +# Rejoice Hallelujah! +print(Fore.GREEN) +print(f"Created \"{repo_name}\" locally!") +print(Style.RESET_ALL) +os.system('code .') \ No newline at end of file diff --git a/Windows/remote.py b/Windows/remote.py new file mode 100644 index 0000000..be0a8fc --- /dev/null +++ b/Windows/remote.py @@ -0,0 +1,62 @@ +import os +import sys + +from colorama import init, Fore, Style +from github import Github + +""" +Author: Red Williams (Red-CS) +Email: red.devcs@gmail.com + +July 18, 2020 +""" + +"""Creates and pushes a repository locally and remotely with the passed arguments""" + +# Color is beautiful! +init() + +# Set passed repository attributes +repo_name = str(sys.argv[1]) +repo_description = str(sys.argv[2]) +if str(sys.argv[3]) == "Public": + repo_publicity = False +else: + repo_publicity = True + + +_dir = "{}\\\\{}".format(os.environ.get("PWFA-Path"), repo_name) + +# Login to GitHub +token = os.environ.get("PWFA-Token") +g = Github(token) +user = g.get_user() +login = user.login + +# Create remote repository +repo = user.create_repo(name=repo_name, + description=repo_description, + private=repo_publicity) + +# Create local directory and change into said directory +if not os.path.isdir(_dir): + os.mkdir(_dir) +os.chdir(_dir) + +# TODO Add README.md commit message parameter in choose.py +commands = [f'echo # {repo.name} >> README.md', + 'git init', + f'git remote add origin https://github.com/{login}/{repo.name}.git', + 'git add .', + 'git commit -m "Initial commit"', + 'git push -u origin master'] + +# Initialize local repository and push to GitHub +for command in commands: + os.system(command) + +print(Fore.GREEN) +print(f"Created \"{_dir}\" locally and pushed to GitHub!") +print(f"Check it out at https://github.com/{login}/{repo.name}.git") +print(Style.RESET_ALL) +os.system('code .') # TODO Add if/else block and os.environ.get for setting code editor preference, or another tag \ No newline at end of file diff --git a/Windows/remove.bat b/Windows/remove.bat new file mode 100644 index 0000000..6838189 --- /dev/null +++ b/Windows/remove.bat @@ -0,0 +1,37 @@ +@echo off +setlocal + +cd /d %~dp0 + +rem Author: Red Williams (Red-CS) +rem Email: red.devcs@gmail.com + +rem July 18, 2020 + +rem pyParams variable to contain python script's parameters +rem Helper flag for parameter presence. default to 0/FALSE. +set prmOk=0 + +rem Variable to contain python script name to use. default is remote. +set pyName=remove + +rem Process batch parameters +:getParam + +set pyParams=%pyParams% %1 +set prmOk=1 + +shift +rem After SHIFT, %0 is replaced by %1, %1 replaced by %2, %2 replaced by %3, etc. +if "%~1" neq "" goto getParam + +rem Check python script's parameter presence +if %prmOk% == 0 ( + echo Batch parameter is missing. + goto :eof +) + +python %pyName%.py%pyParams% + +cd .. +:eof \ No newline at end of file diff --git a/Windows/remove.py b/Windows/remove.py new file mode 100644 index 0000000..9e910ed --- /dev/null +++ b/Windows/remove.py @@ -0,0 +1,208 @@ +import os +import stat +import sys + +from colorama import init, Fore, Style +from github import Github + +""" +Author: Red Williams (Red-CS) +Email: red.devcs@gmail.com + +July 18, 2020 +""" + +def remove(): + """Removes first a remote repository, then a local one. If a local + repository isn't found, it will abort (since this is mainly for GitHub) + Note that the argument called is os.environ.get() can be anything, as + long as it is definied in your user variable list. + """ + # Setup + + # Activiate color mode! + init() + + if len(sys.argv) == 1: + general_usage() + sys.exit(0) + + elif len(sys.argv) > 2: + print(f"Syntax Error: Command requires only one argument, {int(len(sys.argv) - 1)} were given.") + general_usage() + sys.exit(1) + + # Log in + token = os.environ.get("PWFA-Token") + g = Github(token) + user = g.get_user() + login = user.login + + list = ["-l", "--list"] + + # Remove remote repository + + # remove -l, --list + if str(sys.argv[1]) in list: + repo_number = 0 + print() + for repo in user.get_repos(): + repo_number += 1 + print(f" {repo_number}. {repo.name}") + print() + sys.exit(0) + else: + try: + + git_url = "https://github.com/" + + # remove -X + if ( + str(sys.argv[1]).startswith("-") and + str(sys.argv[1])[1:].isnumeric() + ): + passed_int = int(str(sys.argv[1])[1:]) + local_repo_name = user.get_repos()[passed_int - 1].name + repo_url = "{}{}".format(git_url, + user.get_repos()[passed_int - 1].full_name) + + # Confirm deletion + if ask_delete_repo(repo_url): + user.get_repos()[passed_int - 1].delete() + print(f"Deleted repository {repo_url}") + else: + print("Remote repository not deleted.") + else: + # remove repoName + passed_str = str(sys.argv[1]) + local_repo_name = passed_str + repo_url = "{}{}".format(git_url, + user.get_repo(passed_str).full_name) + + # Confirm deletion + if ask_delete_repo(repo_url): + user.get_repo(passed_str).delete() + print(f"Deleted repository {repo_url}") + else: + print("Remote repository not deleted.") + except: + # TODO Run refactor local to test other possible repo name + print(f"Naming Error: Error in finding remote repository \"{local_repo_name}\"") + sys.exit(1) + + # Move on to local or exit + if not ask_continue_local(): + sys.exit(0) + + # Remove local repository + + path = os.environ.get("PWFA-Path") + + # Search local repos with dashes + if os.path.isdir(f"{path}\\\\{local_repo_name}"): + + path += "\\\\" + local_repo_name + + # Delete if selected + if ask_delete_repo(local_repo_name): + remove_local_directory(path, local_repo_name) + else: + print("Local repository not deleted.\n") + + # Search local repos with spaces + elif os.path.isdir(f"{path}\\{refactor_local(local_repo_name)}"): + + local_repo_name = refactor_local(local_repo_name) + path += "\\\\" + local_repo_name + + # Delete if selected + if ask_delete_repo(path): + remove_local_directory(path, local_repo_name) + else: + print("Local repository not deleted.\n") + + # Local repository not found + else: + print("A directory with that name could not be found.") + +def ask_delete_repo(repo_name): + """Prompts the user if they are sure they want to delete the + repository. Used for both deleting the local and remote repository. + There is no auto confirm tag since this is a special process, I don't + want anyone to accidentally delete a repository. + """ + print() + print(Fore.RED) + print(f"Warning! Executing this command would remove {repo_name}") + print("Are you sure you want to delete this repository (y/n)? ", end=Style.RESET_ALL) + usr = input() + return usr.lower() == "y" + +def ask_continue_local(): + """Prompts the user if they want to continue to search for and delete + a local repository after being asked to delete a remote repository. + """ + print() + print() + usr = input("Continue to search for and delete a local repository (y/n)? ") + return usr.lower() == "y" + +def refactor_local(repo_name): + """Changes the name of the repository staged for remote deletion to + test if it was saved under a slightly different name locally. For example + and as you know, GitHub repository names have dashes instead of spaces. + This project allows for repository names with spaces. Thus, a remote name + could be "Remote-Repository" while a local name could be "Remote Repository" + This method changes the passed repo_name by replacing dashes with spaces. + Note that repository names with apostrophes (') also appear with dashes, + so don't use those when creating a repository with this project. + """ + local_name = "" + for char in repo_name: + if char == "-": + local_name += " " + else: + local_name += char + return local_name + +def remove_local_directory(directory_path, directory_name): + """Removes all files, directories, and sub directories of a + local repository, printing what is deleted with every iteration. + Note some files initialized with git are read only and can't be + deleted normally. This gives access and deletes the proper files, + giving a better output if there is an error. + """ + print() + for root_path, directories, files in os.walk(directory_path, topdown=False): + relative_path = root_path[root_path.index(directory_name):] + for name in files: + filename = os.path.join(root_path, name) + os.chmod(filename, stat.S_IWUSR) + os.remove(filename) + print(" Deleted File: {}\\{}".format(relative_path, name)) + for name in directories: + os.rmdir(os.path.join(root_path, name)) + print(" Deleted Directory: {}\\{}".format(relative_path, name)) + os.rmdir(directory_path) + print() + print(f" Deleted Parent Directory: {directory_path}") + print() + +def general_usage(): + """Prints general usage of the remove command""" + print() + print("Usage:") + print(" remove \n") + + print("Commands:") + print(" create\t\t\t\tCreate a repository.") + print(" remove\t\t\t\tRemove a repository.") + print() + print("Required Parameters:") + print(" -l, --list\t\t\t\tPrints a list of your remote repositories.") + print(" -X \t\t\t\tRemoves the Xth repository. View list by typing \"remove -l\".") + print(" \t\t\tRemoves the remote repository with the given name.") + print() + +if __name__ == "__main__": + remove() diff --git a/Windows/requirements.txt b/Windows/requirements.txt new file mode 100644 index 0000000..9cffd63 --- /dev/null +++ b/Windows/requirements.txt @@ -0,0 +1,2 @@ +PyGithub +colorama \ No newline at end of file diff --git a/windows_OS/README.md b/windows_OS/README.md deleted file mode 100644 index 4fef476..0000000 --- a/windows_OS/README.md +++ /dev/null @@ -1,24 +0,0 @@ -### pre-setup: -``` -create env vars : -> projects directory as - "mp" -> Github tocken as - "gt" -``` - -### setup: -```bash -git clone "https://github.com/wikyprash/projectInitializerAutomation.git" -cd projectInitializerAutomation -pip install -r requirements.txt - -path: -"projectInitializerAutomation" folder directory to path -``` - -### Usage: -```bash -Command to run the program type - -'create ' -'create ' - for just locally -``` diff --git a/windows_OS/create.bat b/windows_OS/create.bat deleted file mode 100644 index 8e3e0d0..0000000 --- a/windows_OS/create.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off - -set fn=%1 -set flag=%2 -cd /d %~dp0 - -If "%1"=="" ( - echo "error" -) else ( - if "%2"=="" ( - python remote.py %fn% %flag% - ) else ( - if "%2"=="l" ( - python local.py %fn% - ) - ) - ) diff --git a/windows_OS/local.py b/windows_OS/local.py deleted file mode 100644 index 4c61a59..0000000 --- a/windows_OS/local.py +++ /dev/null @@ -1,21 +0,0 @@ -import sys -import os - -foldername = str(sys.argv[1]) -path = os.environ.get('mp') -_dir = path + '/' + foldername - -try: - os.mkdir(_dir) - os.chdir(_dir) - os.system('git init') - os.system(f'echo "# {foldername}" > README.md') - os.system('git add README.md') - os.system('git commit -m "first commit"') - - print(f'{foldername} created locally') - os.system('code .') - - -except: - print("create l") diff --git a/windows_OS/remote.py b/windows_OS/remote.py deleted file mode 100644 index e842a0f..0000000 --- a/windows_OS/remote.py +++ /dev/null @@ -1,33 +0,0 @@ -import sys -import os -from github import Github - -foldername = str(sys.argv[1]) -path = os.environ.get('mp') # add projects dirctory to the env vars -token = os.environ.get('gt') # add github token to the env vars -_dir = path + '/' + foldername - -g = Github(token) -user = g.get_user() -login = user.login -repo = user.create_repo(foldername) - -commands = [f'echo "# {repo.name}" >> README.md', - 'git init', - f'git remote add origin https://github.com/{login}/{foldername}.git', - 'git add .', - 'git commit -m "Initial commit"', - 'git push -u origin master'] - -if sys.argv[2] == "g": - os.mkdir(_dir) - os.chdir(_dir) - - for c in commands: - os.system(c) - - print(f'{foldername} created locally') - os.system('code .') - -else: - print("create ") diff --git a/windows_OS/requirements.txt b/windows_OS/requirements.txt deleted file mode 100644 index b393fb0..0000000 --- a/windows_OS/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -PyGithub \ No newline at end of file