aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-11-05 11:24:59 -0400
committerBobby <[email protected]>2022-11-05 11:24:59 -0400
commit0de002263f6f9f105ec08303ce814d7c13e763e7 (patch)
tree59d6cf9b9884e824fff57f5f5816ed232789718f
parent53d051d3ae76e3608be6ddcae81afb61238e1a64 (diff)
downloadtexty-0de002263f6f9f105ec08303ce814d7c13e763e7.tar.xz
texty-0de002263f6f9f105ec08303ce814d7c13e763e7.zip
docs: Update Wording
-rw-r--r--README.md31
-rwxr-xr-xbin/configure4
-rw-r--r--setup.py55
3 files changed, 73 insertions, 17 deletions
diff --git a/README.md b/README.md
index e99acdc..1c5eaaa 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,33 @@
# Texty
Text Editor
+## Quick Start
+
+To get started immediately, you can run the `setup.py` script. This is a Python script that is used to do a lot of things. It can be thought of as a manager script for this project. It is used to install requirements, run the project, and more. To run the script, type the following command in your terminal:
+
+ python3 setup.py start
+
+This will run the script and allow you to configure aliases for the project using the file `bin/configure`. Once the script runs successfully, you can run the project by running the following command in your terminal to configure aliases for the project:
+
+ source bin/configure
+
+> **Note:** You need to run the `source bin/configure` command every time you open a new terminal window.
+
+After running the above command, you can run setup script by running the `setup` command and the commit script by running the `commit` command. For more infomation on the commit script, see [Committing Changes](#committing-changes) section below.
+
+If you need further help, you can pair `-h` or `--help` option with any of the commands to get help for that command. For example, to get help for the `setup` command, run the following command:
+
+ setup -h
+
+Similarly, to get help for the `commit` command, run the following command:
+
+ commit --help
+
+A virtual environment is created automatically when you run the `setup.py` script. If you ran the script successfully, you can skip the next step and go ahead and activate the virtual environment:
+
+ source .venv/bin/activate
+
+At this point, you are ready to start contributing to the project by making changes to the code and submitting pull requests.
## Contributing Guidelines
@@ -23,6 +50,8 @@ Before you start contributing, there are a few things you need to have installed
### Making Changes
+> You can skip this step if you ran the `setup.py` script successfully.
+
You should start by [forking this repository](https://github.com/luciferreeves/texty/fork) and then cloning it to your local machine. If you need help with this, you can follow [this guide](https://help.github.com/articles/fork-a-repo/). Once you have cloned the repository, you can start making changes.
> **Note**: You must be working in a virtual environment. If you don't know what that is, you can read more about it [here](https://docs.python.org/3/tutorial/venv.html). To create a virtual environment, run the following command:
@@ -31,7 +60,7 @@ You should start by [forking this repository](https://github.com/luciferreeves/t
This will create a virtual environment named `env`. This environment will be used to install the project's dependencies and will be ignored by Git. To activate the environment, run the following command:
- source env/bin/activate
+ source .venv/bin/activate
This will activate the virtual environment. You can now install the project's dependencies by running the following command:
diff --git a/bin/configure b/bin/configure
index c3c14dc..7a0e88e 100755
--- a/bin/configure
+++ b/bin/configure
@@ -3,5 +3,5 @@ alias commit="./commit.sh"
alias setup="python3 setup.py"
echo "Added aliases for commit and setup."
echo ""
-echo "Run 'setup' to start the setup again."
-echo "Run 'commit' to commit changes. Run commit -h for help."
+echo "Run 'setup' to start the setup again. Run 'setup -h' for more options."
+echo "Run 'commit' to commit changes. Run 'commit -h' for help."
diff --git a/setup.py b/setup.py
index 57acedd..652e42d 100644
--- a/setup.py
+++ b/setup.py
@@ -3,6 +3,7 @@
# run sorter, linter, start and build the project and more. It will be a
# constantly evolving script as the project evolves.
+import importlib.util
import logging as logger
import os
import subprocess
@@ -11,6 +12,24 @@ import sys
logger.basicConfig(stream=sys.stdout, level=logger.DEBUG)
+def install_pip(package_name):
+ # check if package is installed
+ if importlib.util.find_spec(package_name) is None:
+ # install package
+ logger.info(f"Installing {package_name}...")
+ subprocess.check_call(
+ [sys.executable, "-m", "pip", "-q", "install", package_name]
+ )
+
+
+DEV_PACKAGES = ["black", "isort", "click"]
+for package in DEV_PACKAGES:
+ install_pip(package)
+
+import click
+import inquirer
+
+
class Setup:
QUIET_INSTALL = "pip install -q -r requirements.txt"
@@ -22,21 +41,11 @@ class Setup:
if not os.path.exists(".venv"):
self.shell_run("python3 -m venv .venv")
logger.info("Virtual environment created.")
- self.shell_run("source .venv/bin/activate")
- logger.info("Virtual environment activated.")
logger.info("Installing requirements...")
self.shell_run(self.QUIET_INSTALL)
- self.install_pip("black")
- self.install_pip("isort")
self.git()
- def install_pip(self, package_name):
- logger.info(f"Installing {package_name}...")
- self.shell_run(f"pip install -q {package_name}")
-
def git(self):
- import inquirer
-
username = self.shell_run("git config --global user.name")
if username == "":
questions = [
@@ -81,8 +90,8 @@ alias commit="./commit.sh"
alias setup="python3 setup.py"
echo "Added aliases for commit and setup."
echo ""
-echo "Run 'setup' to start the setup again."
-echo "Run 'commit' to commit changes. Run commit -h for help."
+echo "Run 'setup' to start the setup again. Run 'setup -h' for more options."
+echo "Run 'commit' to commit changes. Run 'commit -h' for help."
""".format(
os.environ["SHELL"]
)
@@ -97,10 +106,28 @@ You may want to configure aliases for commit and setup scripts.
To do so, run the configurator binary:
source bin/configure
+
+You may also want to activate the virtual environment, if you haven't already:
+
+ source .venv/bin/activate
"""
)
+CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
+
+
[email protected](context_settings=CONTEXT_SETTINGS)
+def cli():
+ pass
+
+
[email protected](help="Start the setup.")
+def start():
+ Setup().start()
+
+
+cli.add_command(start)
+
if __name__ == "__main__":
- setup = Setup()
- setup.start()
+ cli()