Skip to content

Commit

Permalink
WIP: Create command, templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jamonholmgren committed Nov 29, 2023
1 parent 8cb6b07 commit 237f19f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Installation

First, alias the curl command so it looks prettier:
First, alias the `qub` command to the following:

```
alias qub="curl -fsSL https://raw.githubusercontent.com/jamonholmgren/qub/main/src/cli.sh | bash -s --"
Expand All @@ -18,9 +18,6 @@ qub --version
qub --help
```

```
## License

MIT -- see [LICENSE](LICENSE) for details.
```
45 changes: 41 additions & 4 deletions src/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
VERSION="0.0.1"

# colors
RED='\033[0;31m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
GRAY='\033[0;37m'
DKGRAY='\033[1;30m'
END='\033[0m' # End Color

# Print header
Expand Down Expand Up @@ -45,9 +48,43 @@ fi
# Create command

if [[ $1 == "create" ]]; then
echo "Creating new Qub project..."
echo ""
echo "Coming soon!"
echo "Creating new Qub QB64 website project..."
echo ""
echo -e "${YELLOW}What domain will this be hosted on?${END} ${DKGRAY}(e.g. jamon.dev)${END}"
read DOMAIN

# Check for any whitespace in the domain name
if [[ $DOMAIN =~ [[:space:]] ]]; then
echo ""
echo -e "${RED}Domain name cannot contain whitespace.${END}"
echo ""
exit 1
fi

# Check if the folder exists (DOMAIN)
if [[ -d $DOMAIN ]]; then
echo ""
echo -e "${RED}Folder already exists.${END}"
echo ""
exit 1
fi

# Make the folder
mkdir $DOMAIN
mkdir $DOMAIN/bin

GITHUB_TEMPLATE="https://raw.githubusercontent.com/jamonholmgren/qub/main/template"

# Copy files from Github
curl -s $GITHUB_TEMPLATE/README.md > $DOMAIN/README.md
curl -s $GITHUB_TEMPLATE/app.bas > $DOMAIN/app.bas
curl -s $GITHUB_TEMPLATE/bin/install_qb64 > $DOMAIN/bin/install_qb64

# Make the binary files executable
chmod +x $DOMAIN/bin/*

# Replace the domain name in the README
sed -i "s/\$DOMAIN/$DOMAIN/g" $DOMAIN/README.md

exit 0
fi
2 changes: 1 addition & 1 deletion template/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NAME QBasic Website
# $DOMAIN QBasic Website

This is a website powered by [QB64](https://www.qb64.org/) and [Qub](https://qub.jamon.dev).

Expand Down
Empty file added template/app.bas
Empty file.

0 comments on commit 237f19f

Please sign in to comment.