mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 06:34:25 -04:00
rename archivebox setup to archivebox install
This commit is contained in:
parent
4334c74548
commit
8c3342afe5
5 changed files with 26 additions and 27 deletions
|
@ -12,8 +12,7 @@ from typing import Optional, List, IO, Union, Iterable
|
|||
from pathlib import Path
|
||||
|
||||
from archivebox.config import DATA_DIR
|
||||
from ..misc.checks import check_data_folder, check_migrations
|
||||
from ..misc.logging import stderr
|
||||
from archivebox.misc.logging import stderr
|
||||
|
||||
from importlib import import_module
|
||||
|
||||
|
@ -21,6 +20,10 @@ BUILTIN_LIST = list
|
|||
|
||||
CLI_DIR = Path(__file__).resolve().parent
|
||||
|
||||
# rewrite setup -> install for backwards compatibility
|
||||
if sys.argv[1] == 'setup':
|
||||
sys.argv[1] = 'install'
|
||||
|
||||
|
||||
# def list_subcommands() -> Dict[str, str]:
|
||||
# """find and import all valid archivebox_<subcommand>.py files in CLI_DIR"""
|
||||
|
@ -46,7 +49,7 @@ SUBCOMMAND_MODULES = {
|
|||
|
||||
'init': 'archivebox_init',
|
||||
'config': 'archivebox_config',
|
||||
'setup': 'archivebox_setup',
|
||||
'install': 'archivebox_install',
|
||||
|
||||
'add': 'archivebox_add',
|
||||
'remove': 'archivebox_remove',
|
||||
|
@ -98,7 +101,7 @@ CLI_SUBCOMMANDS = LazySubcommands()
|
|||
|
||||
# these common commands will appear sorted before any others for ease-of-use
|
||||
meta_cmds = ('help', 'version') # dont require valid data folder at all
|
||||
main_cmds = ('init', 'config', 'setup') # dont require existing db present
|
||||
main_cmds = ('init', 'config', 'setup', 'install') # dont require existing db present
|
||||
archive_cmds = ('add', 'remove', 'update', 'list', 'status') # require existing db present
|
||||
fake_db = ("oneshot",) # use fake in-memory db
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ import argparse
|
|||
|
||||
from typing import Optional, List, IO
|
||||
|
||||
from ..main import init
|
||||
from archivebox.misc.util import docstring
|
||||
from archivebox.config import DATA_DIR
|
||||
from ..logging_util import SmartFormatter, reject_stdin
|
||||
from ..main import init
|
||||
|
||||
|
||||
@docstring(init.__doc__)
|
||||
|
@ -33,17 +33,22 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
|
|||
help='Run any updates or migrations without rechecking all snapshot dirs',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--setup', #'-s',
|
||||
'--install', #'-s',
|
||||
action='store_true',
|
||||
help='Automatically install dependencies and extras used for archiving',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--setup', #'-s',
|
||||
action='store_true',
|
||||
help='DEPRECATED: equivalent to --install',
|
||||
)
|
||||
command = parser.parse_args(args or ())
|
||||
reject_stdin(__command__, stdin)
|
||||
|
||||
init(
|
||||
force=command.force,
|
||||
quick=command.quick,
|
||||
setup=command.setup,
|
||||
install=command.install or command.setup,
|
||||
out_dir=pwd or DATA_DIR,
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
__package__ = 'archivebox.cli'
|
||||
__command__ = 'archivebox setup'
|
||||
__command__ = 'archivebox install'
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
|
@ -11,14 +11,14 @@ from typing import Optional, List, IO
|
|||
from archivebox.misc.util import docstring
|
||||
from archivebox.config import DATA_DIR
|
||||
from ..logging_util import SmartFormatter, reject_stdin
|
||||
from ..main import setup
|
||||
from ..main import install
|
||||
|
||||
|
||||
@docstring(setup.__doc__)
|
||||
@docstring(install.__doc__)
|
||||
def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional[str]=None) -> None:
|
||||
parser = argparse.ArgumentParser(
|
||||
prog=__command__,
|
||||
description=setup.__doc__,
|
||||
description=install.__doc__,
|
||||
add_help=True,
|
||||
formatter_class=SmartFormatter,
|
||||
)
|
||||
|
@ -30,7 +30,7 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
|
|||
command = parser.parse_args(args or ()) # noqa
|
||||
reject_stdin(__command__, stdin)
|
||||
|
||||
setup(
|
||||
install(
|
||||
# force=command.force,
|
||||
out_dir=Path(pwd) if pwd else DATA_DIR,
|
||||
)
|
|
@ -81,7 +81,7 @@ class ShellConfig(BaseConfigSet):
|
|||
@model_validator(mode='after')
|
||||
def validate_not_running_as_root(self):
|
||||
attempted_command = ' '.join(sys.argv[:3])
|
||||
if self.PUID == 0 and attempted_command != 'setup':
|
||||
if self.PUID == 0 and attempted_command not in ('setup', 'install'):
|
||||
# stderr('[!] ArchiveBox should never be run as root!', color='red')
|
||||
# stderr(' For more information, see the security overview documentation:')
|
||||
# stderr(' https://github.com/ArchiveBox/ArchiveBox/wiki/Security-Overview#do-not-run-as-root')
|
||||
|
|
|
@ -68,7 +68,6 @@ from archivebox.misc.logging import stderr, hint
|
|||
from archivebox.misc.checks import check_data_folder
|
||||
from archivebox.config.legacy import (
|
||||
write_config_file,
|
||||
DEPENDENCIES,
|
||||
load_all_config,
|
||||
CONFIG,
|
||||
USER_CONFIG,
|
||||
|
@ -129,7 +128,7 @@ def help(out_dir: Path=DATA_DIR) -> None:
|
|||
{lightred}Example Use:{reset}
|
||||
mkdir -p ~/archivebox/data; cd ~/archivebox/data
|
||||
archivebox init
|
||||
archivebox setup
|
||||
archivebox install
|
||||
archivebox version
|
||||
archivebox status
|
||||
|
||||
|
@ -214,16 +213,8 @@ def version(quiet: bool=False,
|
|||
)
|
||||
print()
|
||||
|
||||
print('[pale_green3][i] Old dependency versions:[/pale_green3]')
|
||||
for name, dependency in DEPENDENCIES.items():
|
||||
print(printable_dependency_version(name, dependency))
|
||||
|
||||
# add a newline between core dependencies and extractor dependencies for easier reading
|
||||
if name == 'ARCHIVEBOX_BINARY':
|
||||
print()
|
||||
|
||||
print()
|
||||
print('[pale_green1][i] New dependency versions:[/pale_green1]')
|
||||
print('[pale_green1][i] Dependency versions:[/pale_green1]')
|
||||
for name, binary in reversed(list(settings.BINARIES.items())):
|
||||
if binary.name == 'archivebox':
|
||||
continue
|
||||
|
@ -270,7 +261,7 @@ def run(subcommand: str,
|
|||
|
||||
|
||||
@enforce_types
|
||||
def init(force: bool=False, quick: bool=False, setup: bool=False, out_dir: Path=DATA_DIR) -> None:
|
||||
def init(force: bool=False, quick: bool=False, install: bool=False, out_dir: Path=DATA_DIR) -> None:
|
||||
"""Initialize a new ArchiveBox collection in the current directory"""
|
||||
|
||||
from core.models import Snapshot
|
||||
|
@ -421,8 +412,8 @@ def init(force: bool=False, quick: bool=False, setup: bool=False, out_dir: Path=
|
|||
if html_index.exists():
|
||||
html_index.rename(f"{index_name}.html")
|
||||
|
||||
if setup:
|
||||
run_subcommand('setup', pwd=out_dir)
|
||||
if install:
|
||||
run_subcommand('install', pwd=out_dir)
|
||||
|
||||
if Snapshot.objects.count() < 25: # hide the hints for experienced users
|
||||
print()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue