Skip to content

Commit

Permalink
fix: Biscuit CLI - clone command will notify user about implicit host…
Browse files Browse the repository at this point in the history
… assumptions, add new dev mode flag
  • Loading branch information
tomlin7 committed Jun 8, 2024
1 parent b2519ff commit ea9cf91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/biscuit/git/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .git import Git
from .git import *
from .releases import Releases
from .repo import GitRepo
10 changes: 6 additions & 4 deletions src/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
## Feature
A CLI application for Biscuit using Python click (suggestions for other CLI libs open).

Support for the following commands:
### Commands
- `biscuit --help` - Show help for the Biscuit CLI
- `biscuit --version` - Show the version of Biscuit
- `biscuit --dev` - Start Biscuit in development mode
- `biscuit clone [URL]` - Clone a Biscuit repository
- `biscuit diff [FILE1] [FILE2]` - Show the differences between the local and remote Biscuit repositories


Extension development commands:
### Extension dev commands (not implemented)
- `biscuit extension create` - Create a new extension
- `biscuit extension test` - Test an extension
- `biscuit extension test` - Test an extension
17 changes: 10 additions & 7 deletions src/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@
import click

from src import App, __version__, get_app_instance
from src.biscuit.git import URL
from src.cli import extensions


@click.group(invoke_without_command=True)
@click.version_option(__version__, "-v", "--version", message="Biscuit v%(version)s")
@click.help_option("-h", "--help")
@click.pass_context
def cli(ctx, path=None):
@click.option("--dev", is_flag=True, help="Run in development mode")
def cli(path=None, dev=False):
"""Biscuit CLI"""

click.echo(f"Biscuit v{__version__}")
if ctx.invoked_subcommand is None and path:
click.echo(f"Opening {path}")
click.echo(f"Biscuit v{__version__} {'(dev) 🚧' if dev else '🚀'}")


@cli.result_callback()
def process_commands(processors, path=None):
def process_commands(processors, path=None, dev=False):
"""Process the commands"""

if path:
path = str(Path(path).resolve())
click.echo(f"Opening {path}")

app = get_app_instance(open_path=path)

if processors:
Expand All @@ -45,7 +46,9 @@ def clone(url) -> Callable[[App, str], None]:
if not url:
url = click.prompt("Git repository url", type=str)

click.echo(f"Cloning repository from {url}")
click.echo(
f"Cloning repository from {'https://github.com/' if not URL.match(url) else ''}{url}"
)
return lambda app, url=url: app.clone_repo(url, new_window=False)


Expand Down

0 comments on commit ea9cf91

Please sign in to comment.