Skip to content

Commit

Permalink
Merge pull request #30 from sneekyfoxx/testing
Browse files Browse the repository at this point in the history
update README.md options.py
  • Loading branch information
sneekyfoxx authored Jun 29, 2024
2 parents c1e1532 + f6fc244 commit 1b248a8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 40 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@ del requirements.txt
```
</details>

## Do It Yourself

<details>
<summary><strong>Options</strong></summary>

```bash
# Download the Github repository
git clone https://gihub.com/sneekyfoxx/ziggy && cd ziggy

# Use Python zippapp
python3 -m zipapp -o ziggy -p "/usr/bin/env python3" -c pkg

# Move the executable zip file to a location of your choice

# Linux
mv ./ziggy ~/.local/bin/ziggy

# Windows
move .\ziggy c:\Windows\System32\ziggy
# or
pyinstaller -f -n ziggy .\ziggy\pkg
move .\ziggy c:\Windows\System32\ziggy
```
</details>

## ziggy Usage

<details>
Expand All @@ -42,4 +67,3 @@ ziggy fetch VERSION # fetch the given supporting compiler version from the
ziggy use VERSION # use the supplied version as the default compiler
```
</details>

46 changes: 23 additions & 23 deletions pkg/modules/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,6 @@
utils.get_json()
utils.set_constants()

# ziggy activate version
def option_use(version: str, /) -> None:
""" Use the the given compiler as the
primary compiler version if installed.
"""
if not isinstance(version, str):
raise SystemExit(f"[<function option_activate>] expected 'version: str' got 'version: {type(version).__name__}'")
else:
if not utils.Path(utils.constants['ziggy']).exists():
utils.Path(utils.constants['ziggy']).mkdir()

symlink = utils.constants['symlink']
if utils.Path(symlink).is_symlink() and utils.constants[version] in utils.get_symlink_name():
exitcode = utils.output(f'{version!r} is already in use.', mode='warn', exitcode=1)
raise SystemExit(exitcode)
else:
name = utils.have_compiler(version)
utils.shell_operation(option='link', name=name)
exitcode = utils.output(f'Using {name!r}', mode='normal', exitcode=0)
raise SystemExit(exitcode)

# ziggy delete version
def option_delete(version: str, /) -> None:
""" Delete the given compiler version if
Expand Down Expand Up @@ -93,12 +72,33 @@ def option_help() -> None:
reset = "\x1b[0m"
utils.sys.stdout.write(f'\n{cyan}Options Description{reset}\n')
utils.sys.stdout.write('------- -----------\n')
utils.sys.stdout.write(f' {green}use{reset} VERSION {cyan}use version as the primary compiler{reset}\n\n')
utils.sys.stdout.write(f' {green}delete{reset} VERSION {cyan}delete the given compiler version{reset}\n\n')
utils.sys.stdout.write(f' {green}fetch{reset} VERSION {cyan}fetch the given compiler version from the internet{reset}\n\n')
utils.sys.stdout.write(f' {green}help{reset} {cyan}display all options for ziggy{reset}\n\n')
utils.sys.stdout.write(f' {green}use{reset} VERSION {cyan}use version as the primary compiler{reset}\n\n')
utils.sys.stdout.write(f'{cyan}Usage{reset}\n-----\n')
utils.sys.stdout.write(f' {yellow}ziggy{reset} {green}use{reset} stable or master\n')
utils.sys.stdout.write(f' {yellow}ziggy{reset} {green}delete{reset} stable or master\n')
utils.sys.stdout.write(f' {yellow}ziggy{reset} {green}fetch{reset} stable or master\n\n')
utils.sys.stdout.write(f' {yellow}ziggy{reset} {green}use{reset} stable or master\n')
raise SystemExit(0)

# ziggy use version
def option_use(version: str, /) -> None:
""" Use the the given compiler as the
primary compiler version if installed.
"""
if not isinstance(version, str):
raise SystemExit(f"[<function option_activate>] expected 'version: str' got 'version: {type(version).__name__}'")
else:
if not utils.Path(utils.constants['ziggy']).exists():
utils.Path(utils.constants['ziggy']).mkdir()

symlink = utils.constants['symlink']
if utils.Path(symlink).is_symlink() and utils.constants[version] in utils.get_symlink_name():
exitcode = utils.output(f'{version!r} is already in use.', mode='warn', exitcode=1)
raise SystemExit(exitcode)
else:
name = utils.have_compiler(version)
utils.shell_operation(option='link', name=name)
exitcode = utils.output(f'Using {name!r}', mode='normal', exitcode=0)
raise SystemExit(exitcode)
16 changes: 0 additions & 16 deletions pkg/modules/utils.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
""" Utility functions for simplifying 'ziggy' operations. """

# fetch:
# stable
# master
#
# use:
# stable
# master
#
# delete:
# stable
# master
#
# Constants:
# stable_version = 0.13.0
# unstable_version = "master"

import os
import sys
import platform
Expand Down

0 comments on commit 1b248a8

Please sign in to comment.