Giter VIP home page Giter VIP logo

cli's People

Contributors

dependabot[bot] avatar jnsgruk avatar korvyashka avatar muratursavas avatar nicomiguelino avatar renatgalimov avatar rusko124 avatar sergey-borovkov avatar staniwan avatar vpetersson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

Change how tokens are inputed

We currently enter tokens this way:

$ screenly login [redacted]
Login credentials have been saved.

There issue with this is that by default (unless you prefix the command with a space), the token will be saved in your shell's history. This should be considered a security issue.

A better approach is to simply ask the user for this in an interactive dialogue.

Improve hello world app

Here's the new version:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Hello World</title>
    <script src="screenly.js?version=1"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://playground.srly.io/bootstrap/theme/playground-theme.css">
  </head>
  <body >
    <main>
        <div class="container">
            <div class="px-4 py-5 my-5 text-center">
                <h1 class="display-5 fw-bold">Greetings <span id="greeting"></span>!</h1>
                <p>I'm <span id="screen-name"></span>. Assuming you've pinned me in the right location, I'm located in <span id="screen-location"></span> (more precisely at latitude <span id="screen-lat"></span>&#176; and longitude <span id="screen-lng"></span>&#176;).</p>
                <p>My Screenly ID is <span id="screen-hostname"></span> (which convenientely is also my hostname), and I'm running on a <span id="screen-hardware"></span>.</p>
            </div>
    </main>
    </div>
  </body>
  <script>
    document.getElementById("greeting").innerText = screenly.settings.greeting;
    document.getElementById("screen-name").innerText = screenly.metadata.screen_name;
    document.getElementById("screen-location").innerText = screenly.metadata.location;
    document.getElementById("screen-hostname").innerText = screenly.metadata.hostname;
    document.getElementById("screen-hardware").innerText = screenly.metadata.hardware;
    document.getElementById("screen-lat").innerText = screenly.metadata.coordinates[0];
    document.getElementById("screen-lng").innerText = screenly.metadata.coordinates[1];
  </script>
</html>
app_id: 
description: ''
icon: ''
author: ''
homepage_url: ''
settings:
  greeting:
    type: text
    default_value: stranger
    title: greeting
    optional: true
    help_text: An example of a setting that is used in index.html

Open browser when running `edge-app run`

When you run edge-app run as follows, we just print the URL:

$ screenly edge-app run
Edge App emulator is running at http://127.0.0.1:51265/edge/1/index.html

It would be handy if we open the browser with the given path too.

Tweak the way headers are set

Currently, the way we set headers for web assets is as follows:

$ screenly asset $ASSET_ID set-headers —header k=v
[...]

When we do this, we wipe all existing headers in the process. This is somewhat unexpected.

An alternative approach is to add the following headers sub-commands:

  • add
    • Adds on or more headers (passed on as comma separated key-value pairs)
  • remove
    • Removes on or more headers (passed on as comma separated key-value pairs)
  • update
    • Updates on or more headers (passed on as comma separated key-value pairs)
  • clear
    • Removes all headers

An alternative approach would be something like this:

$ screenly asset $ASSET_ID headers add k=v,foo=bar
[...]

If you then just want to update say the key k, you can use

$ screenly asset $ASSET_ID headers update k=foobar
[...]

This is open for debate, but I think this would be more user friendly.

Resolve YAML syntax

Right now, our YAML doesn't pass regular linting. In the long run we want to move to StrictYAML.

$ yamllint screenly.yml
1:1       warning  missing document start "---"  (document-start)

`edge-app version list` isn't sorted

Here's the output of the version list command:

$ screenly edge-app version list                                                                                                                                                           +----------+---------------------------------------+-----------+-----------+
| Revision | Description                           | Published | Channels  |
+----------+---------------------------------------+-----------+-----------+
| 1        | Displays the current weather and time ||           |
+----------+---------------------------------------+-----------+-----------+
| 2        | Displays the current weather and time ||           |
+----------+---------------------------------------+-----------+-----------+
| 3        | Displays the current weather and time ||           |
+----------+---------------------------------------+-----------+-----------+
| 11       | Displays the current weather and time || stable    |
+----------+---------------------------------------+-----------+-----------+
| 4        | Displays the current weather and time ||           |
+----------+---------------------------------------+-----------+-----------+
| 5        | Displays the current weather and time ||           |
+----------+---------------------------------------+-----------+-----------+
| 6        | Displays the current weather and time ||           |
+----------+---------------------------------------+-----------+-----------+
| 7        | Displays the current weather and time ||           |
+----------+---------------------------------------+-----------+-----------+
| 8        | Displays the current weather and time ||           |
+----------+---------------------------------------+-----------+-----------+
| 9        | Displays the current weather and time || candidate |
+----------+---------------------------------------+-----------+-----------+
| 10       | Displays the current weather and time ||           |
+----------+---------------------------------------+-----------+-----------+

As can be seen here, it isn't properly sorted as it should be.

Create Brew Formula

Brew is the most popular package manager for macOS.

Because we expect most/many of the users of the Screenly CLI to use macOS, it makes sense to create a package for our CLI.

References

Edge App titles could be unique.

Overview

Similar titles (even though they have the different IDs) could cause confusion among users. Here's a sample console output after running screenly edge-app list:

+----------------------------+--------------+
| Id                         | Title        |
+----------------------------+--------------+
| [redacted]                 | edge-app-1   |
+----------------------------+--------------+
| [redacted]                 | clock-app    |
+----------------------------+--------------+
| [redacted]                 | clock-app    |
+----------------------------+--------------+
| [redacted]                 | clock-test-1 |
+----------------------------+--------------+

We can notice that there are two occurences of the clock-app.

Fix add screen command

I tried adding a screen just now:

$ screenly screen add 2k7e-th9s
Error occurred: WrongResponseStatus(200)

The screen was paired properly, but got an error above.

When repeating the command I got the following:

$ screenly screen add 2k7eth9s
Error occurred: WrongResponseStatus(400)

Action Items

  • Fix the status code in the API end-point (should return 201, not 200)
  • Add handling for 400 response code when the screen has already been paired

Fix issues with `edge-app run`

Change generage-mock-data

Right now we have this:

$ screenly edge-app run
Error: No mock-data exist. Please run "screenly edge-app generate-mock-data" and try again.

As discussed, let's move generate-mock-data to a sub-command for run like this screenly edge-app run --generate-mock-data

Resolve Hello World

If you do edge-app create and then try to run it with edge-app run, it's currently broken and yields the following output:

Greetings !

I'm . Assuming you've pinned me in the right location, I'm located in (more precisely at latitude ° and longitude °).

My Screenly ID is (which conveniently is also my hostname), and I'm running on a .

Let's make sure we actually get the Hello World to work.

Tweak JSON help message

This is currently how the help for JSON is displayed:

$ screenly --help
[...]
  -j, --json <JSON>  Enables json output
[...]

This is incorrect. <JSON> implies that there is some sort of input here, while in reality it just formats the output to JSON.

The output should read:

  -j, --json   Enables JSON output

Fix JSON output

It appears as some of our parsing is wrong.

$ screenly asset list --json  | jq
parse error: Invalid numeric literal at line 1, column 14

Looking closer into this, the error comes from the following debug message:

$ screenly asset list --json | head -n 1
2022-12-09T15:07:14.949Z INFO  [screenly] [

Reformat empty edge app list

We currently show an empty table:

$ screenly edge-app list
+----+-------+
| Id | Title |
+----+-------+

Instead we should probably show a text message saying 'No Edge Apps found.'

Add unit-tests that check user input

Screen deletion is a dangerous operation, but it's not unit-tested.
I suggest to add unit tests that check user interaction.

[ ] - Unit test that screen doesn't get deleted without user confirmation, or when it's not given correctly.

Build Nix package

We should adopt a cli.nix file so that the repo can be installed through Nix.

400 Error when promoting Edge-App from Apple Silicon Machine

Environment Information:
CPU - Apple M1 Pro
OS - 14.1.2 (23B92)
Terminal - Warp
CLI Installed via Homebrew

brew info screenly-cli
==> screenly/screenly-cli/screenly-cli: stable v0.2.1
Command line interface is intended for quick interaction with Screenly through terminal.
https://github.com/Screenly/cli
/opt/homebrew/Cellar/screenly-cli/v0.2.1 (7 files, 11.9MB) *
  Built from source on 2023-12-07 at 21:57:22
From: https://github.com/screenly/homebrew-screenly-cli/blob/HEAD/Formula/screenly-cli.rb
License: MIT
==> Dependencies
Build: rust ✔

When promoting an Edge-App using the command screenly edge-app version promote --latest or screenly edge-app version promote --revision=X the CLI returns Response: Ok("") Failed to promote edge app version: unknown error: 400. All other commands leading up to the promotion step successfully complete without issue.

Screenshot 2023-12-12 at 10 13 59 AM

This behavior has been reproduced using the Weather and Power BI sample Edge Apps that are located in the Screenly/Playground repository.

Working directory copied from the Mac to a Windows 11 machine and was able to successfully promote both Edge-Apps using the CLI.

Was able to reproduce the issue, from different locations, using different networks/ISP providers to rule out possible network traffic filtering.

Screenly CLI not compatible with Raspberry Pi Hardware

Hi,

Would be nice to make Screenly CLI compatible with the main hardware used for Screenly (Raspberry Pi).
Homebrew is not compatible with ARM processor.

Is there a way to use the CLI on Raspberry Pi (Ubuntu Server or Raspberry Pi OS)?

Thanks for your feedback!

`jq` parsing fail of screen list

(sed '1d' is to work around issue in #20.)

It appears as the JSON we generate is broken sometimes:

> $ screenly screen list --json | sed '1d' | jq
{
  "config": {
    "audio_output": "hdmi",
    "disable_overscan": 0,
    "display_rotate": 0,
    "framebuffer_height": 0,
    "framebuffer_width": 0,
    "hdmi_boost": 2,
    "hdmi_drive": 0,
    "hdmi_force_hotplug": true,
    "hdmi_group": 0,
    "hdmi_mode": 0,
    "hdmi_pixel_encoding": 0,
    "hdmi_timings": "",
    "overscan_bottom": 0,
    "overscan_left": 0,
    "overscan_right": 0,
    "overscan_scale": 0,
    "overscan_top": 0,
    "play_history_enabled": false,
    "shuffle_playlist": false,
    "use_composite": false,
    "use_composite_ntsc": false,
    "use_composite_pal": false,
    "verify_ssl": true
  },
  "coords": [
    59.324,
    18.0486
  ],
  "created_at": "2021-09-22T10:39:21+00:00",
  "debug": false,
  "hardware_version": "Raspberry Pi 3B+",
  "hostname": "[redacted]",
  "id": "[redacted]",
  "in_sync": false,
  "interface": "eth0",
  "is_enabled": true,
  "last_ip": null,
  "last_ping": "2021-09-23T11:55:35.776+00:00",
  "last_screenshot": "https://us-assets.screenlyapp.com/018KXAT7680007YRRPFJ9WTG0W/screenshots/x/y",
  "last_screenshot_time": "2021-09-23T11:44:00.94+00:00",
  "load_avg": "0.81",
  "local_ip": "192.168.202.180",
  "location": "Stockholm, Sweden",
  "mac": "[redacted]",
  "name": "My Screen",
  "signal_strength": null,
  "software_version": "Screenly 2 Player",
  "status": "Offline",
  "team": "[redacted]",
  "team_id": "[redacted]",
  "timezone": "Europe/Stockholm",
  "type": "hardware",
  "uptime": "90134.67",
  "ws_open": false
}
parse error: Expected value before ',' at line 57, column 4

Include API TOKEN in command

Hi,

Is there a way to execute commands with specific API TOKEN included in the command?
For ie. : screenly screen list abcdefgh (abcdefgh beeing the token)

I would like to execute commands and switch between multiple tokens (including everything in a script.sh file).

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.