Skip to content

Commit

Permalink
feat: init command for tips
Browse files Browse the repository at this point in the history
  • Loading branch information
himkt committed Mar 21, 2024
1 parent d7c39ec commit 8601534
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bin/tips
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ def show_tips(args: argparse.Namespace) -> None:
print(tip)


def init_tips(args: argparse.Namespace) -> None:
tips_file: pathlib.Path = tips_home() / args.name / "tips"
if tips_file.exists():
print(f"Tips for {args.name} already exists.")
return
tips_file.parent.mkdir(exist_ok=True)
tips_file.touch()
print(f"Created tips for {args.name}")


def edit_tips(args: argparse.Namespace) -> None:
tips_file = tips_home() / args.name / "tips"
EDITOR = os.environ.get("EDITOR", "vim")
Expand All @@ -45,6 +55,7 @@ def main(args: argparse.Namespace) -> None:
"list": list_tips,
"show": show_tips,
"edit": edit_tips,
"init": init_tips,
}
if args.sub_parser is None:
commands = ", ".join(actions.keys())
Expand All @@ -66,6 +77,9 @@ if __name__ == "__main__":
edit_parser = sub_parsers.add_parser("edit")
edit_parser.add_argument("name", type=str, default=None)

init_parser = sub_parsers.add_parser("init")
init_parser.add_argument("name", type=str)

list_parser = sub_parsers.add_parser("list")

args = parser.parse_args()
Expand Down

0 comments on commit 8601534

Please sign in to comment.