-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sub-command with a root context function
- Loading branch information
1 parent
b42392b
commit 0c9d19d
Showing
9 changed files
with
137 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,4 @@ Icon* | |
.settings | ||
.idea/ | ||
.local/ | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,53 @@ | ||
from arger import Arger | ||
import sh | ||
from delegator import run | ||
|
||
arger = Arger(description="Common set of tasks to run") | ||
|
||
|
||
class Color: | ||
HEADER = '\033[95m' | ||
OKBLUE = '\033[94m' | ||
OKGREEN = '\033[92m' | ||
WARNING = '\033[93m' | ||
FAIL = '\033[91m' | ||
BOLD = '\033[1m' | ||
UNDERLINE = '\033[4m' | ||
|
||
# reset | ||
END = '\033[0m' | ||
|
||
|
||
def prun(*cmd, **kwargs): | ||
cmd = " ".join(cmd) | ||
print(f'{Color.OKGREEN} $ {cmd}{Color.END}') | ||
c = run(cmd, **kwargs) | ||
print(c.out) | ||
print(c.err) | ||
return c | ||
|
||
|
||
@arger.add_cmd | ||
def release(type: str): | ||
"""Bump version, tag and push them. | ||
# todo: create an Enum | ||
:param type: one of patch, minor, major, prepatch, preminor, premajor, prerelease. as supported by poetry version | ||
""" | ||
version = sh() | ||
prun('poetry', 'version', type) | ||
c = prun('poetry', 'version') | ||
_, version = c.out.split() | ||
prun('git status') | ||
msg = 'chore: bump version' | ||
|
||
answer = input(f'{msg}\nAdd to commit: [Y/n]?') | ||
if answer.lower() in {'no', 'n'}: | ||
return | ||
prun('git add .') | ||
prun(f'git commit -m {msg}') | ||
prun(f'git tag v{version}') | ||
prun('git push') | ||
prun('git push --tags') | ||
|
||
|
||
if __name__ == '__main__': | ||
arger.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters