forked from platformio/platformio-core
Implemented "platformio search" command
This commit is contained in:
1 parent
673a41c21c
commit
bdfe849c97
9 files changed
+66
-14
No files matched your search
@@ -3,7 +3,7 @@
|
||||
|
||||
from click import argument, command, option, secho
|
||||
|
||||
from platformio.platforms.base import PlatformFactory
|
||||
from platformio.platforms._base import PlatformFactory
|
||||
|
||||
|
||||
@command("run", short_help="Install new platforms")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from click import command, echo, option, secho, style
|
||||
|
||||
from platformio.exception import ProjecEnvsNotAvaialable, UndefinedEnvPlatform
|
||||
from platformio.platforms.base import PlatformFactory
|
||||
from platformio.platforms._base import PlatformFactory
|
||||
from platformio.util import get_project_config
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from click import argument, command, echo, style
|
||||
|
||||
from platformio.platforms._base import PlatformFactory
|
||||
from platformio.util import get_platforms
|
||||
|
||||
|
||||
@command("search", short_help="Search for development platforms")
|
||||
@argument("query")
|
||||
def cli(query):
|
||||
for platform in get_platforms():
|
||||
p = PlatformFactory().newPlatform(platform)
|
||||
name = p.get_name()
|
||||
shinfo = p.get_short_info()
|
||||
|
||||
search_data = "%s %s" % (name, shinfo)
|
||||
if query != "all" and query.lower() not in search_data.lower():
|
||||
continue
|
||||
|
||||
echo("{name:<20} - {info}".format(name=style(name, fg="cyan"),
|
||||
info=shinfo))
|
||||
@@ -34,6 +34,13 @@ class BasePlatform(object):
|
||||
def get_name(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_short_info(self):
|
||||
if self.__doc__:
|
||||
doclines = [l.strip() for l in self.__doc__.splitlines()]
|
||||
return " ".join(doclines).strip()
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
def install(self, with_packages, without_packages):
|
||||
requirements = []
|
||||
pm = PackageManager(self.get_name())
|
||||
@@ -3,10 +3,14 @@
|
||||
|
||||
from os.path import join
|
||||
|
||||
from platformio.platforms.base import BasePlatform
|
||||
from platformio.platforms._base import BasePlatform
|
||||
|
||||
|
||||
class AtmelavrPlatform(BasePlatform):
|
||||
"""
|
||||
An embedded platform for Atmel AVR microcontrollers
|
||||
(with Arduino Framework)
|
||||
"""
|
||||
|
||||
PACKAGES = {
|
||||
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
|
||||
from os.path import join
|
||||
|
||||
from platformio.platforms.base import BasePlatform
|
||||
from platformio.platforms._base import BasePlatform
|
||||
|
||||
|
||||
class Timsp430Platform(BasePlatform):
|
||||
"""
|
||||
An embedded platform for TI MSP430 microcontrollers
|
||||
(with Energia Framework)
|
||||
"""
|
||||
|
||||
PACKAGES = {
|
||||
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
|
||||
from os.path import join
|
||||
|
||||
from platformio.platforms.base import BasePlatform
|
||||
from platformio.platforms._base import BasePlatform
|
||||
|
||||
|
||||
class TitivaPlatform(BasePlatform):
|
||||
"""
|
||||
An embedded platform for TI TIVA C ARM microcontrollers
|
||||
(with Energia Framework)
|
||||
"""
|
||||
|
||||
PACKAGES = {
|
||||
|
||||
|
||||
+12
-3
@@ -1,7 +1,7 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from os import getcwd, utime
|
||||
from os import getcwd, listdir, utime
|
||||
from os.path import dirname, expanduser, isfile, join, realpath
|
||||
from platform import architecture, system
|
||||
from subprocess import PIPE, Popen
|
||||
@@ -14,6 +14,10 @@ except ImportError:
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
|
||||
def get_system():
|
||||
return (system() + architecture()[0][:-3]).lower()
|
||||
|
||||
|
||||
def get_home_dir():
|
||||
return expanduser("~/.platformio")
|
||||
|
||||
@@ -35,8 +39,13 @@ def get_project_config():
|
||||
return cp
|
||||
|
||||
|
||||
def get_system():
|
||||
return (system() + architecture()[0][:-3]).lower()
|
||||
def get_platforms():
|
||||
platforms = []
|
||||
for p in listdir(join(get_source_dir(), "platforms")):
|
||||
if p.startswith("_") or not p.endswith(".py"):
|
||||
continue
|
||||
platforms.append(p[:-3])
|
||||
return platforms
|
||||
|
||||
|
||||
def change_filemtime(path, time):
|
||||
|
||||
Reference in new issue
Block a user