-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from njgheorghita/uninstall
Uninstall & list packages
- Loading branch information
Showing
37 changed files
with
277 additions
and
99 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from ethpm.backends.ipfs import BaseIPFSBackend, InfuraIPFSBackend, LocalIPFSBackend | ||
|
||
|
||
def get_ipfs_backend(ipfs: bool = None) -> BaseIPFSBackend: | ||
def get_ipfs_backend(ipfs: bool = False) -> BaseIPFSBackend: | ||
if ipfs: | ||
return LocalIPFSBackend() | ||
return InfuraIPFSBackend() |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from argparse import Namespace | ||
from pathlib import Path | ||
|
||
from ethpm_cli._utils.ipfs import get_ipfs_backend | ||
from ethpm_cli.constants import ETHPM_DIR_NAME | ||
|
||
|
||
class Config: | ||
""" | ||
Class to manage CLI config options | ||
- IPFS Backend | ||
- Target ethpm_dir | ||
""" | ||
|
||
def __init__(self, args: Namespace) -> None: | ||
if "local_ipfs" in args: | ||
self.ipfs_backend = get_ipfs_backend(args.local_ipfs) | ||
else: | ||
self.ipfs_backend = get_ipfs_backend() | ||
|
||
if args.ethpm_dir is None: | ||
self.ethpm_dir = Path.cwd() / ETHPM_DIR_NAME | ||
if not self.ethpm_dir.is_dir(): | ||
self.ethpm_dir.mkdir() | ||
else: | ||
self.ethpm_dir = args.ethpm_dir |
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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import argparse | ||
from pathlib import Path | ||
|
||
|
||
def get_ethpm_parser() -> argparse.ArgumentParser: | ||
parser = argparse.ArgumentParser(description="ethpm-cli") | ||
subparsers = parser.add_subparsers(help="commands", dest="command") | ||
|
||
scrape_parser = subparsers.add_parser( | ||
"scrape", help="Scrape for new VersionRelease events." | ||
) | ||
scrape_parser.add_argument( | ||
"--ipfs-dir", | ||
dest="ipfs_dir", | ||
action="store", | ||
type=Path, | ||
help="path to specific IPFS assets dir.", | ||
) | ||
scrape_parser.add_argument( | ||
"--start-block", | ||
dest="start_block", | ||
action="store", | ||
type=int, | ||
help="Block number to begin scraping from.", | ||
) | ||
|
||
install_parser = subparsers.add_parser("install", help="Install uri") | ||
install_parser.add_argument( | ||
"uri", | ||
action="store", | ||
type=str, | ||
help="IPFS / Github / Registry URI of package you want to install.", | ||
) | ||
install_parser.add_argument( | ||
"--ethpm-dir", | ||
dest="ethpm_dir", | ||
action="store", | ||
type=Path, | ||
help="Path to specific ethpm_packages dir.", | ||
) | ||
install_parser.add_argument( | ||
"--alias", action="store", type=str, help="Alias for installing package." | ||
) | ||
install_parser.add_argument( | ||
"--local-ipfs", | ||
dest="local_ipfs", | ||
action="store_true", | ||
help="Flag to use locally running IPFS node.", | ||
) | ||
|
||
list_parser = subparsers.add_parser("list", help="List installed packages") | ||
list_parser.add_argument( | ||
"--ethpm-dir", | ||
dest="ethpm_dir", | ||
action="store", | ||
type=Path, | ||
help="Path to specific ethpm_packages dir.", | ||
) | ||
return parser | ||
|
||
|
||
ETHPM_PARSER = get_ethpm_parser() |
Oops, something went wrong.