forked from platformio/platformio-core
Implemented "platformio search" command
This commit is contained in:
13
README.rst
13
README.rst
@@ -55,8 +55,8 @@ Quickstart
|
|||||||
# Install platformio
|
# Install platformio
|
||||||
$ pip install platformio && pip install --egg scons
|
$ pip install platformio && pip install --egg scons
|
||||||
|
|
||||||
# Print availalbe development platforms for installing
|
# Print all availalbe development platforms for installing
|
||||||
$ platformio search
|
$ platformio search all
|
||||||
|
|
||||||
# Install new development platform
|
# Install new development platform
|
||||||
$ platformio install SomePlatform
|
$ platformio install SomePlatform
|
||||||
@@ -137,14 +137,15 @@ To print all available commands and options:
|
|||||||
``platformio search``
|
``platformio search``
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Search for available development platforms:
|
Search for development platforms:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ platformio search "Query"
|
# Print all available development platforms
|
||||||
|
$ platformio search all
|
||||||
|
|
||||||
You can leave search "Query" as empty. In this case ``platformio`` will print
|
# Filter platforms by "Query"
|
||||||
all available platforms.
|
$ platformio search "Query"
|
||||||
|
|
||||||
|
|
||||||
``platformio install``
|
``platformio install``
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from click import argument, command, option, secho
|
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")
|
@command("run", short_help="Install new platforms")
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
from click import command, echo, option, secho, style
|
from click import command, echo, option, secho, style
|
||||||
|
|
||||||
from platformio.exception import ProjecEnvsNotAvaialable, UndefinedEnvPlatform
|
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
|
from platformio.util import get_project_config
|
||||||
|
|
||||||
|
|
||||||
|
23
platformio/commands/search.py
Normal file
23
platformio/commands/search.py
Normal file
@@ -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):
|
def get_name(self):
|
||||||
raise NotImplementedError()
|
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):
|
def install(self, with_packages, without_packages):
|
||||||
requirements = []
|
requirements = []
|
||||||
pm = PackageManager(self.get_name())
|
pm = PackageManager(self.get_name())
|
@@ -3,10 +3,14 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from platformio.platforms.base import BasePlatform
|
from platformio.platforms._base import BasePlatform
|
||||||
|
|
||||||
|
|
||||||
class AtmelavrPlatform(BasePlatform):
|
class AtmelavrPlatform(BasePlatform):
|
||||||
|
"""
|
||||||
|
An embedded platform for Atmel AVR microcontrollers
|
||||||
|
(with Arduino Framework)
|
||||||
|
"""
|
||||||
|
|
||||||
PACKAGES = {
|
PACKAGES = {
|
||||||
|
|
||||||
|
@@ -3,10 +3,14 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from platformio.platforms.base import BasePlatform
|
from platformio.platforms._base import BasePlatform
|
||||||
|
|
||||||
|
|
||||||
class Timsp430Platform(BasePlatform):
|
class Timsp430Platform(BasePlatform):
|
||||||
|
"""
|
||||||
|
An embedded platform for TI MSP430 microcontrollers
|
||||||
|
(with Energia Framework)
|
||||||
|
"""
|
||||||
|
|
||||||
PACKAGES = {
|
PACKAGES = {
|
||||||
|
|
||||||
|
@@ -3,10 +3,14 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from platformio.platforms.base import BasePlatform
|
from platformio.platforms._base import BasePlatform
|
||||||
|
|
||||||
|
|
||||||
class TitivaPlatform(BasePlatform):
|
class TitivaPlatform(BasePlatform):
|
||||||
|
"""
|
||||||
|
An embedded platform for TI TIVA C ARM microcontrollers
|
||||||
|
(with Energia Framework)
|
||||||
|
"""
|
||||||
|
|
||||||
PACKAGES = {
|
PACKAGES = {
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||||
# See LICENSE for details.
|
# 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 os.path import dirname, expanduser, isfile, join, realpath
|
||||||
from platform import architecture, system
|
from platform import architecture, system
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import PIPE, Popen
|
||||||
@@ -14,6 +14,10 @@ except ImportError:
|
|||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
|
|
||||||
|
|
||||||
|
def get_system():
|
||||||
|
return (system() + architecture()[0][:-3]).lower()
|
||||||
|
|
||||||
|
|
||||||
def get_home_dir():
|
def get_home_dir():
|
||||||
return expanduser("~/.platformio")
|
return expanduser("~/.platformio")
|
||||||
|
|
||||||
@@ -35,8 +39,13 @@ def get_project_config():
|
|||||||
return cp
|
return cp
|
||||||
|
|
||||||
|
|
||||||
def get_system():
|
def get_platforms():
|
||||||
return (system() + architecture()[0][:-3]).lower()
|
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):
|
def change_filemtime(path, time):
|
||||||
|
Reference in New Issue
Block a user