Code Monkey home page Code Monkey logo

cli's Introduction

cli

The Zoo command line tool.

The instructions below refer to instructions for contributing to the repo.

For the CLI docs for end users refer to: https://zoo.dev/docs/cli/manual

Installing

On MacOS, you can use Homebrew:

brew tap kittycad/kittycad
brew install kittycad
zoo --help   

For all other installs, see the instructions on the latest release.

Updating the API spec

Updating the API spec is as simple as updating the spec.json file. The macro will take it from there when you cargo build. It likely might need some tender love and care to make it a nice command like the other generated ones if it is out of the ordinary.

Only create, edit, view/get, list, delete commands are generated. The rest are bespoke and any generation lead to something that seemed harder to maintain over time. But if you are brave you can try.

For examples of the macro formatting, checkout some of the commands under src/ like cmd_file or cmd_user.

Note: If you update the API spec here, you will likely want to bump the spec for the kittycad.rs repo as well since that is where the API client comes from.

Running the tests

The tests use the ZOO_TEST_TOKEN variables for knowing how to authenticate.

Releasing a new version

  1. Make sure the Cargo.toml has the new version you want to release.
  2. Run make tag this is just an easy command for making a tag formatted correctly with the version.
  3. Push the tag (the result of make tag gives instructions for this)
  4. Everything else is triggered from the tag push. Just make sure all the tests and cross compilation pass on the main branch before making and pushing a new tag.

Building

To build, simply run cargo build like usual.

Make sure to update to the latest stable rustc: for example, if you use rustup, run rustup update.

Cross compiling

If you're on Debian or Ubuntu, install the required dependencies by running .github/workflows/cross-deps.sh. Otherwise, look there to see what packages are required.

Then, simply run make. Binaries will be available in cross/.

If you want to only build one of the cross targets, supply the CROSS_TARGETS environment variable:

CROSS_TARGETS=x86_64-unknown-linux-musl make

If you get an error about md5sum on mac when running make release, you probably need to brew install coreutils

cli's People

Contributors

jessfraz avatar dependabot[bot] avatar adamchalmers avatar zoo-github-actions-auth[bot] avatar github-actions[bot] avatar irev-dev avatar iterion avatar lf94 avatar ahl avatar hanbollar avatar gserena01 avatar

Stargazers

Jason Morganson avatar  avatar astrolemonade avatar Travis A. Everett avatar Josh Mize avatar Jason Gurtz avatar Nick Armstrong avatar Blain Smith avatar GAURAV avatar Coool (github.com/Coool) avatar Jason Huggins avatar Joey Buiteweg avatar Cody Krieger avatar Dan avatar

Watchers

Jonathan Tran avatar Lucian avatar  avatar  avatar Mike Farrell avatar David Harvey-Macaulay avatar Vonni Williams avatar Pierre Jacquier avatar Ben Crabbe avatar  avatar Kostas Georgiou avatar  avatar

Forkers

icodein ahl

cli's Issues

Serde Error on Login

Seems related to the fact that I have not set an avatar yet:

Serde Error:
1 | ...08-25T21:19:44.962Z","image":"","discord":"brwhale","phone":"...
| ^ invalid value: string "", expected relative URL without a base at line 1 column 154

Note that on terminal with fixed width font, that carat points to the string for "image", which is empty.

Add flag to "zoo kcl export" to enforce deterministic output

https://github.com/KittyCAD/kcl-samples/blob/main/.github/workflows/output-from-kcl-samples.yml#L31 runs sed to try to trim the date out and hope for determinism.
Instead, there should be a flag to force the output to be deterministic.

This enable users to refactor kcl code and ensure that the result stays the same. As a project using kcl grows, the ability to safely refactor will become critical in large teams.

This may not always be possible for all formats, and that's useful insight in itself as the tool can assert this explicitly, instead of hoping for the best.

Tarball of release binaries is broken

Our homebrew formula downloads a tarball from https://dl.zoo.dev/releases/cli/v0.2.36/kittycad-cli.tar.gz

This tarball is supposed to contain the zoo CLI executables/binaries for various architectures. However, it doesn't. The files aren't binaries, they're XML docs, each of which says

<?xml version='1.0' encoding='UTF-8'?>
<Error>
  <Code>NoSuchKey</Code>
  <Message>The specified key does not exist.</Message>
</Error>

The releases are getting built properly, because https://dl.zoo.dev/releases/cli/v0.2.36/zoo-aarch64-apple-darwin contains actual binaries. So there's something going wrong when we create the tarball for homebrew. The XML error looks like an S3 error, so maybe it's looking for an S3 key called "kittycad" but it's actually called "zoo", or vice-versa.

This has been happening since at least version 0.2.33.

API errors are not actually being shown

In https://github.com/KittyCAD/format/issues/189 Frank gets a HTTP 400 error from the API, but the CLI doesn't actually show what the error is. It just shows

Unexpected Response: Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("api.kittycad.io")), port: None, path: "/file/conversion/ply/gltf", query: None, fragment: None }, status: 400, headers: {"date": "Wed, 13 Sep 2023 18:18:47 GMT", "content-type": "application/json", "content-length": "168", "x-request-id": "9d9d208e-73ed-45cc-988a-6ef30e7e62e9", "strict-transport-security": "max-age=15724800; includeSubDomains", "cf-cache-status": "DYNAMIC", "report-to": "{\"endpoints\":[{\"url\":\"https:\/\/a.nel.cloudflare.com\/report\/v3?s=DuqbgM4pRYX9FL2l3QBWvrUgoYsQWQrcPyB7JtpUyhlAxF%2FI2uK%2BQXpghYFFWvYgxd28rJQZ2zlEV5kL0fpDBLOnjhEAFexYr3DuuaFV%2FPdW4QJQq2lhk5w7QEuE0BoepI8yANg6qOvsQTj%2Bpho%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}", "nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}", "set-cookie": "__cflb=02DiuForeBv2DVnYSFPtSfNRmR8hoJ4HciYZCksQzHXLG; SameSite=Lax; path=/; expires=Thu, 14-Sep-23 17:18:47 GMT; HttpOnly", "server": "cloudflare", "cf-ray": "80626505b9b0439d-EWR", "alt-svc": "h3=\":443\"; ma=86400"} }

This sucks for a few reasons:

  • We're printing raw debug strings, we should print something prettier
  • This does not show the HTTP body which contains the actual error message and code

Instead, we should check what the API error is and print them. If there's no API errors, then we should do something else but nicer than this -- not just print raw rust debug strings.

No more err.get_message_line_column() method

@paultag 's recent modeling-app PR added a KCL linter. It removed the type kcl_lib::errors::KclError 's method get_message_line_column which is being used by the CLI.

Either add the method back or change the CLI to use something different

Proposal for `kittycad file view` command

When trying out the CLI for the first time, I wanted to check if file conversions worked but I don't have some of the software that some of those file types need to open. So I ended up having the AutoDesk Online File Viewer open while I worked.

Since we will have pixel streaming possible from the engine with the work within KittyCAD/engine, I was wondering if it would be worthwhile for our users to have a way to view 3D models, for debugging or otherwise, within the terminal itself without too much effort. I think it fits our retro-with-superpowers brand.

example usages

  • kittycad file view suzanne.step: basic viewer, using something like https://github.com/hzeller/timg if the terminal supports it
  • kittycad file view --ascii: display the video stream as ASCII characters. Idea from @alteous

The UX of the viewer would be TBD, but maybe as an MVP a sensible default camera position is chosen, and no camera controls are given to the user. Eventually we could support keyboard combinations to pan, zoom, and orbit.

Unread fields on rust 1.79

If you run cargo +1.78 check on this repo, it passes with 0 errors. But if you run cargo +1.79 check it'll fail.
Screenshot 2024-06-15 at 7 35 37 PM

Click for plain text error
warning: field `description` is never read
--> src/config.rs:49:9
 |
47 | pub struct ConfigOption {
 |            ------------ field in this struct
48 |     pub key: String,
49 |     pub description: String,
 |         ^^^^^^^^^^^
 |
 = note: `#[warn(dead_code)]` on by default

warning: field `tmp_file_override` is never read
--> src/iostreams.rs:38:9
 |
11 | pub struct IoStreams {
 |            --------- field in this struct
...
38 |     pub tmp_file_override: Option<std::fs::File>,
 |         ^^^^^^^^^^^^^^^^^

warning: `zoo` (bin "zoo") generated 2 warnings

Weird. I guess the new rustc is smarter about finding dead code. We have to fix this to make CI pass again.

kittycad update is broken on Linux

@greg-kcio encountered a bug when trying to update on Ubuntu. The error is:

No such file or directory (os error 2)

I've attached the strace, but it points to some weird reading of a symlink to the executable itself.

Quickly searching the code, I'm pretty sure it's this line:

// src/cmd_update.rs:30
let current_binary_path = std::env::current_exe()?;

strace.txt

I get the same error on Arch Linux.

Install broken on MacOS with ARM

I run brew tap kittycad/kittycad and then brew install kittycad. I get:

==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
==> Fetching kittycad/kittycad/kittycad
==> Downloading https://dl.zoo.dev/releases/cli/v0.2.32/kittycad-cli.tar.gz
Already downloaded: /Users/adamchalmers/Library/Caches/Homebrew/downloads/5452d95c15d036ad4450eee7a2a4a755eb7bc601eb5b4499f97dec9ff5f42559--kittycad-cli.tar.gz
==> Installing kittycad from kittycad/kittycad
Error: An exception occurred within a child process:
  Errno::ENOENT: No such file or directory - aarch64_darwin/zoo
Screenshot 2024-03-29 at 8 12 02 AM

Theory

The homebrew formulae we publish (https://github.com/KittyCAD/homebrew-kittycad/blob/main/Formula/kittycad.rb) references a tar.gz. When I download that tar, it expands into this:

Screenshot 2024-03-29 at 8 14 18 AM

I think our release is creating aarch64_darwin/kittycad instead of aarch64_darwin/zoo.

Update release instructions for Windows

In the releases there are install instructions for various platforms, but the windows instructions are wrong as they use linux paths e.g.

windows/amd64

# Export the sha256sum for verification.
$ export KITTYCAD_CLI_SHA256="ee4a911b6814262b4e4d83c877654715a6442d401dbd2a104ebf31e82101e024"


# Download and check the sha256sum.
$ curl -fSL "https://dl.kittycad.io/releases/cli/v0.0.9/cli-windows-amd64" -o "/usr/local/bin/kittycad" \
	&& echo "${KITTYCAD_CLI_SHA256}  /usr/local/bin/kittycad" | sha256sum -c - \
	&& chmod a+x "/usr/local/bin/kittycad"


$ echo "kittycad cli installed!"

# Run it!
$ kittycad -h

Changes probably need to be made to cli/basic.mk

Looking at our cli install action might help as it works with a Windows runner, though it still uses bash, perhaps instructions should use powershell. Also adding the cli to %PATH% would be different outside of a github action runner.

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.