forked from platformio/platformio-core
Use "lib_dir" by default for LibraryManager
This commit is contained in:
@@ -7,7 +7,7 @@ import click
|
|||||||
|
|
||||||
from platformio import app, exception
|
from platformio import app, exception
|
||||||
from platformio.libmanager import LibraryManager
|
from platformio.libmanager import LibraryManager
|
||||||
from platformio.util import get_api_result, get_lib_dir
|
from platformio.util import get_api_result
|
||||||
|
|
||||||
LIBLIST_TPL = ("[{id:^14}] {name:<25} {compatibility:<30} "
|
LIBLIST_TPL = ("[{id:^14}] {name:<25} {compatibility:<30} "
|
||||||
"\"{authornames}\": {description}")
|
"\"{authornames}\": {description}")
|
||||||
@@ -100,7 +100,7 @@ def lib_search(query, **filters):
|
|||||||
@click.option("-v", "--version")
|
@click.option("-v", "--version")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def lib_install(ctx, libid, version):
|
def lib_install(ctx, libid, version):
|
||||||
lm = LibraryManager(get_lib_dir())
|
lm = LibraryManager()
|
||||||
for id_ in libid:
|
for id_ in libid:
|
||||||
click.echo(
|
click.echo(
|
||||||
"Installing library [ %s ]:" % click.style(str(id_), fg="green"))
|
"Installing library [ %s ]:" % click.style(str(id_), fg="green"))
|
||||||
@@ -149,7 +149,7 @@ def lib_install_dependency(ctx, data):
|
|||||||
@cli.command("uninstall", short_help="Uninstall libraries")
|
@cli.command("uninstall", short_help="Uninstall libraries")
|
||||||
@click.argument("libid", type=click.INT, nargs=-1)
|
@click.argument("libid", type=click.INT, nargs=-1)
|
||||||
def lib_uninstall(libid):
|
def lib_uninstall(libid):
|
||||||
lm = LibraryManager(get_lib_dir())
|
lm = LibraryManager()
|
||||||
for id_ in libid:
|
for id_ in libid:
|
||||||
info = lm.get_info(id_)
|
info = lm.get_info(id_)
|
||||||
if lm.uninstall(id_):
|
if lm.uninstall(id_):
|
||||||
@@ -160,7 +160,7 @@ def lib_uninstall(libid):
|
|||||||
@cli.command("list", short_help="List installed libraries")
|
@cli.command("list", short_help="List installed libraries")
|
||||||
@click.option("--json-output", is_flag=True)
|
@click.option("--json-output", is_flag=True)
|
||||||
def lib_list(json_output):
|
def lib_list(json_output):
|
||||||
lm = LibraryManager(get_lib_dir())
|
lm = LibraryManager()
|
||||||
items = lm.get_installed().values()
|
items = lm.get_installed().values()
|
||||||
|
|
||||||
if json_output:
|
if json_output:
|
||||||
@@ -179,7 +179,7 @@ def lib_list(json_output):
|
|||||||
@cli.command("show", short_help="Show details about installed library")
|
@cli.command("show", short_help="Show details about installed library")
|
||||||
@click.argument("libid", type=click.INT)
|
@click.argument("libid", type=click.INT)
|
||||||
def lib_show(libid):
|
def lib_show(libid):
|
||||||
lm = LibraryManager(get_lib_dir())
|
lm = LibraryManager()
|
||||||
info = lm.get_info(libid)
|
info = lm.get_info(libid)
|
||||||
click.secho(info['name'], fg="cyan")
|
click.secho(info['name'], fg="cyan")
|
||||||
click.echo("-" * len(info['name']))
|
click.echo("-" * len(info['name']))
|
||||||
@@ -215,7 +215,7 @@ def lib_show(libid):
|
|||||||
metavar="[LIBRARY_ID]")
|
metavar="[LIBRARY_ID]")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def lib_update(ctx, libid):
|
def lib_update(ctx, libid):
|
||||||
lm = LibraryManager(get_lib_dir())
|
lm = LibraryManager()
|
||||||
for id_, latest_version in (lm.get_latest_versions() or {}).items():
|
for id_, latest_version in (lm.get_latest_versions() or {}).items():
|
||||||
if libid and int(id_) not in libid:
|
if libid and int(id_) not in libid:
|
||||||
continue
|
continue
|
||||||
|
@@ -12,15 +12,15 @@ from platformio import telemetry
|
|||||||
from platformio.downloader import FileDownloader
|
from platformio.downloader import FileDownloader
|
||||||
from platformio.exception import LibAlreadyInstalledError, LibNotInstalledError
|
from platformio.exception import LibAlreadyInstalledError, LibNotInstalledError
|
||||||
from platformio.unpacker import FileUnpacker
|
from platformio.unpacker import FileUnpacker
|
||||||
from platformio.util import get_api_result
|
from platformio.util import get_api_result, get_lib_dir
|
||||||
|
|
||||||
|
|
||||||
class LibraryManager(object):
|
class LibraryManager(object):
|
||||||
|
|
||||||
CONFIG_NAME = ".library.json"
|
CONFIG_NAME = ".library.json"
|
||||||
|
|
||||||
def __init__(self, lib_dir):
|
def __init__(self, lib_dir=None):
|
||||||
self.lib_dir = lib_dir
|
self.lib_dir = lib_dir or get_lib_dir()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def download(url, dest_dir):
|
def download(url, dest_dir):
|
||||||
|
@@ -203,7 +203,7 @@ def check_internal_updates(ctx, what):
|
|||||||
if p.is_outdated():
|
if p.is_outdated():
|
||||||
outdated_items.append(platform)
|
outdated_items.append(platform)
|
||||||
elif what == "libraries":
|
elif what == "libraries":
|
||||||
lm = LibraryManager(get_lib_dir())
|
lm = LibraryManager()
|
||||||
outdated_items = lm.get_outdated()
|
outdated_items = lm.get_outdated()
|
||||||
|
|
||||||
if not outdated_items:
|
if not outdated_items:
|
||||||
|
Reference in New Issue
Block a user