18个稳定版本 (3个主要版本)

3.1.0+20150811 2022年4月26日
3.0.0+20150811 2022年3月8日
2.0.4+20150811 2021年4月15日
1.0.14+20150811 2020年7月10日
0.3.6+20150811 2016年9月11日

#2876 in Web编程

Download history 95/week @ 2024-07-02

每月95次下载

MIT 许可证

345KB
5K SLoC

coordinate1 命令行界面(CLI)允许您从终端舒适地使用Google坐标服务的多数功能。

默认情况下,所有输出都打印到标准输出,但可以通过标志将其直接重定向到文件,而无需考虑shell的功能。错误将打印到标准错误,并导致程序退出代码不为零。

如果请求数据结构,这些结构将作为格式化的JSON返回,以便作为其他工具的输入。

关于坐标API的所有其他信息可以在官方文档网站找到。

安装和源代码

使用cargo安装命令行界面:

cargo install google-coordinate1-cli

GitHub上找到源代码

用法

本文档是从coordinate API的20150811版本生成的。CLI的版本是3.1.0

coordinate1 [options]
        custom-field-def
                list <team-id> [-p <v>]... [-o <out>]
        jobs
                get <team-id> <job-id> [-p <v>]... [-o <out>]
                insert <team-id> <address> <lat> <lng> <title> (-r <kv>)... [-p <v>]... [-o <out>]
                list <team-id> [-p <v>]... [-o <out>]
                patch <team-id> <job-id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <team-id> <job-id> (-r <kv>)... [-p <v>]... [-o <out>]
        location
                list <team-id> <worker-email> <start-timestamp-ms> [-p <v>]... [-o <out>]
        schedule
                get <team-id> <job-id> [-p <v>]... [-o <out>]
                patch <team-id> <job-id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <team-id> <job-id> (-r <kv>)... [-p <v>]... [-o <out>]
        team
                list [-p <v>]... [-o <out>]
        worker
                list <team-id> [-p <v>]... [-o <out>]
  coordinate1 --help

Configuration:
  [--scope <url>]...
            Specify the authentication a method should be executed in. Each scope
            requires the user to grant this application permission to use it.
            If unset, it defaults to the shortest scope url for a particular method.
  --config-dir <folder>
            A directory into which we will store our persistent data. Defaults to
            a user-writable directory that we will create during the first invocation.
            [default: ~/.google-service-cli]

配置

程序将所有持久数据存储在~/.google-service-cli目录中的JSON文件中,文件名以coordinate1-开头。您可以使用--config-dir标志在每次调用的基础上更改用于存储配置的目录。

以下段落提供了有关各种类型持久数据的更多信息。

身份验证

大多数API都需要用户对请求进行身份验证。如果是这样,范围确定了授予的权限集。这些权限的粒度通常不超过只读完全访问

如果没有设置,系统将自动选择最小可行的范围,例如,在调用只读方法时,它将只请求只读范围。您可以使用--scope标志直接指定范围。所有适用范围均在相应方法的CLI文档中记录。

第一次使用范围时,系统会要求用户授权。按照CLI给出的说明授权或拒绝。

如果用户认证了作用域,相关的信息将被存储在配置目录中,以JSON格式,例如:~/.google-service-cli/coordinate1-token-<scope-hash>.json。无需手动管理这些令牌。

要撤销授权的认证,请参阅官方文档

应用程序密钥

为了允许任何应用程序使用Google服务,它需要使用Google开发者控制台进行注册。然后逐个为应用程序启用它可能使用的API。大多数API可以免费使用,并且有每日配额。

为了在不强制要求任何人注册自己的应用程序的情况下更方便地使用CLI,CLI自带了一个相应的默认应用程序密钥。这也意味着全球范围内的重用可能会耗尽每日配额。

您可以通过将您自己的密钥文件放在此位置来解决这个问题:~/.google-service-cli/coordinate1-secret.json,前提是已为它启用了所需的coordinate API。这样的密钥文件可以从Google开发者控制台APIs & auth -> Credentials -> Download JSON中下载,并直接使用。

有关如何设置Google项目和启用API的更多信息,请参阅官方文档

调试

尽管CLI尽力提供可用的错误消息,但有时可能需要了解导致特定问题确切的原因。这是通过允许所有客户端服务器通信以标准错误原样输出实现的。

使用--debug标志将错误以Debug表示形式打印到标准错误。

您可以考虑将标准错误重定向到文件,以便于使用,例如:coordinate1 --debug <resource> <method> [options] 2>debug.txt

依赖项

~18–30MB
~560K SLoC