Menziess
11/11/2018 - 9:26 PM

Create basic python project quickly.

Create basic python project quickly.

#!/bin/bash

GREEN='\033[1;32m'
WHITE='\033[0m'
EDITORCONFIG='https://gist.githubusercontent.com/Menziess/97ce53ea86d70e4e95eef6097ea40a72/raw/d0780eba0$
SETTINGS_JSON='https://gist.githubusercontent.com/Menziess/dc3d46c4c7743c08626ea2d325d313a3/raw/05411512$

if [ $# -eq 0 ]
  then
    echo "Please provide a new project name" && exit 1
else
  if [ -d $1 ]; then
    echo $1 "already exists."
    exit 1
  fi
  echo -e "Creating new project: ${GREEN}$1${WHITE}"
fi

mkdir $1
cd $1 

# Create virtual environment
virtualenv venv && 
source venv/bin/activate &&
python -m pip install -U yapf &&

# Download basic config files
curl -o .editorconfig $EDITORCONFIG

# Create vscode settings folder
mkdir .vscode
cd .vscode
curl -o settings.json $SETTINGS_JSON
cd ..

# Create file to start programming
touch app.py

echo -e "${GREEN}"$1 "${WHITE}has been created"

read -r -p "Do you wish to open the project in vscode? [Y/n] " input
 
case $input in
    [yY][eE][sS]|[yY])
 code .
 ;;
esac