Giter VIP home page Giter VIP logo

cli's Issues

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!

Error while creating the edge app on google cloud shell

Screenly CLI looks ok when running the basic commands.

sfaris@cloudshell:~/Screenly-Playground/edge-apps/countdown-timer$ screenly --version
screenly 0.2.8
sfaris@cloudshell:~/Screenly-Playground/edge-apps/countdown-timer$ screenly
Usage: screenly [OPTIONS] <COMMAND>

Commands:
  login     Logins with the token and stores it for further use if it's valid. You can set API_TOKEN environment variable to override used API token
  logout    Logouts and removes stored token
  screen    Screen related commands
  asset     Asset related commands
  playlist  Playlist related commands
  edge-app  Edge App related commands
  help      Print this message or the help of the given subcommand(s)

Options:
  -j, --json     Enables JSON output
  -h, --help     Print help (see more with '--help')
  -V, --version  Print version

Error is when trying to create an app from template

sfaris@cloudshell:~/Screenly-Playground/edge-apps/countdown-timer$ screenly edge-app create --name countdown-timer --in-place
thread 'main' panicked at src/cli.rs:878:48:
Failed to load authentication.: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Same error when creating a new app

sfaris@cloudshell:~/test$ screenly edge-app create --name testAPP 
thread 'main' panicked at src/cli.rs:878:48:
Failed to load authentication.: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
sfaris@cloudshell:~/test$ 

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

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.

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.

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.

Build Nix package

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

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

`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.

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!

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.

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] [

`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

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

Error while installing in Mac via brew

I am getting errors while installing cli via brew, and I noticed that it's fetching the cli v0.2.5 not the latest v0.2.6

brew install screenly-cli
==> Downloading https://formulae.brew.sh/api/formula.jws.json
########################################################################################################################## 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
########################################################################################################################## 100.0%
==> Fetching screenly/screenly-cli/screenly-cli
==> Cloning https://github.com/Screenly/cli.git
Updating /Users/salman/Library/Caches/Homebrew/screenly-cli--git
==> Checking out tag v0.2.6
HEAD is now at ec61476 Merge pull request #163 from Screenly/fix/help_texts
HEAD is now at ec61476 Merge pull request #163 from Screenly/fix/help_texts
==> Installing screenly-cli from screenly/screenly-cli
==> cargo install --bin screenly
Last 15 lines from /Users/salman/Library/Logs/Homebrew/screenly-cli/01.cargo:
   |
help: consider giving `items` an explicit type, where the placeholders `_` are specified
   |
83 |     let items: Box<_> = format_items
   |              ++++++++

   Compiling tracing v0.1.40
   Compiling core-foundation v0.9.3
   Compiling backtrace v0.3.69
   Compiling gimli v0.28.1
For more information about this error, try `rustc --explain E0282`.
error: could not compile `time` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cli v0.2.5 (/private/tmp/screenly-cli-20240802-22074-vj9nge)`, intermediate artifacts can be found at `/private/tmp/screenly-cli-20240802-22074-vj9nge/target`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/screenly/homebrew-screenly-cli/issues

System Info:
MAC OS: 14.6 (23G80)
Chip : Apple M1

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.

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.

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

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)

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.'

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.