Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cli-macro-impl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use std::collections::BTreeMap;

use anyhow::Result;
use inflector::cases::{kebabcase::to_kebab_case, titlecase::to_title_case};
use openapitor::types::exts::{ParameterExt, ParameterSchemaOrContentExt, ReferenceOrExt, TokenStreamExt};
use inflector::cases::kebabcase::to_kebab_case;
use inflector::cases::titlecase::to_title_case;
use openapitor::types::exts::ParameterExt;
use openapitor::types::exts::ParameterSchemaOrContentExt;
use openapitor::types::exts::ReferenceOrExt;
use openapitor::types::exts::TokenStreamExt;
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use quote::format_ident;
use quote::quote;
use serde::Deserialize;
use serde_tokenstream::from_tokenstream;
use syn::ItemEnum;
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ max_width = 120
edition = "2024"
format_code_in_doc_comments = true
format_strings = false
imports_granularity = "Crate"
imports_granularity = "Item"
group_imports = "StdExternalCrate"
13 changes: 7 additions & 6 deletions src/build_kcl_project.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! This module reads a KCL project from disk into memory, so it can be sent over the network.
use std::env::current_dir;

use anyhow::{Result, anyhow};
use camino::{Utf8Path, Utf8PathBuf};
use kittycad_modeling_cmds::{
exec_kcl::{KclFile, KclProject},
shared::safe_filepath::SafeFilepath,
};
use anyhow::Result;
use anyhow::anyhow;
use camino::Utf8Path;
use camino::Utf8PathBuf;
use kittycad_modeling_cmds::exec_kcl::KclFile;
use kittycad_modeling_cmds::exec_kcl::KclProject;
use kittycad_modeling_cmds::shared::safe_filepath::SafeFilepath;

const FILES_TO_SEND_TO_ENGINE: [&str; 18] = [
"kcl", "fbx", "glb", "gltf", "obj", "ply", "step", "stl", "sat", "sab", "model", "catpart", "ipt", "prt", "xpr",
Expand Down
9 changes: 5 additions & 4 deletions src/cmd_alias.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::io::Write;

use anyhow::{Result, bail};
use clap::{Command, CommandFactory, Parser};
use anyhow::Result;
use anyhow::bail;
use clap::Command;
use clap::CommandFactory;
use clap::Parser;

/// Create command shortcuts.
///
Expand Down Expand Up @@ -37,7 +40,6 @@ impl crate::cmd::Command for CmdAlias {
/// ```shell
/// zoo alias delete aabb_mm
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdAliasDelete {
Expand Down Expand Up @@ -99,7 +101,6 @@ impl crate::cmd::Command for CmdAliasDelete {
/// zoo alias set aabb_mm "kcl bounding-box $1 --output-unit mm"
/// zoo aabb_mm my-file.kcl
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdAliasSet {
Expand Down
15 changes: 8 additions & 7 deletions src/cmd_api.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use std::{
collections::HashMap,
fmt::Write as _,
io::{Read, Write},
};
use std::collections::HashMap;
use std::fmt::Write as _;
use std::io::Read;
use std::io::Write;

use anyhow::{Result, anyhow};
use anyhow::Result;
use anyhow::anyhow;
use clap::Parser;
use reqwest::header::CONTENT_TYPE;
use serde::{Deserialize, Serialize};
use serde::Deserialize;
use serde::Serialize;

/// Makes an authenticated HTTP request to the Zoo API and prints the response.
///
Expand Down
1 change: 0 additions & 1 deletion src/cmd_api_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use itertools::Itertools;
/// # convert a step file to an obj file
/// zoo file convert ~/Downloads/cube.step ~/Downloads --output-format obj
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdApiCall {
Expand Down
1 change: 0 additions & 1 deletion src/cmd_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ an issue at https://github.com/KittyCAD/cli/issues/new"#;
/// ```shell
/// zoo app ../main.kcl
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdApp {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd_auth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;

use anyhow::{Result, anyhow};
use anyhow::Result;
use anyhow::anyhow;
use clap::Parser;
use oauth2::TokenResponse;

Expand Down Expand Up @@ -306,7 +307,6 @@ impl crate::cmd::Command for CmdAuthLogin {
/// zoo --host api.zoo.dev auth logout
/// # => log out of specified host
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdAuthLogout {}
Expand Down
7 changes: 5 additions & 2 deletions src/cmd_completion.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use anyhow::Result;
use clap::{Command, CommandFactory, Parser};
use clap_complete::{Shell, generate};
use clap::Command;
use clap::CommandFactory;
use clap::Parser;
use clap_complete::Shell;
use clap_complete::generate;

/// Generate shell completion scripts.
///
Expand Down
10 changes: 7 additions & 3 deletions src/cmd_config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use anyhow::{Result, bail};
use anyhow::Result;
use anyhow::bail;
use clap::Parser;

use crate::config::{CONFIG_OPTIONS, ConfigOption};
use crate::config::CONFIG_OPTIONS;
use crate::config::ConfigOption;

// TODO: make this doc a function that parses from the config the options so it's not hardcoded
/// Manage configuration for `zoo`.
Expand Down Expand Up @@ -171,7 +173,9 @@ impl crate::cmd::Command for CmdConfigList {
mod test {
use pretty_assertions::assert_eq;

use crate::{cmd::Command, config, config::Config};
use crate::cmd::Command;
use crate::config;
use crate::config::Config;

pub struct TestItem {
name: String,
Expand Down
22 changes: 9 additions & 13 deletions src/cmd_file.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use std::{
hash::{DefaultHasher, Hash, Hasher},
str::FromStr,
};
use std::hash::DefaultHasher;
use std::hash::Hash;
use std::hash::Hasher;
use std::str::FromStr;

use anyhow::Result;
use base64::prelude::*;
use clap::Parser;
use kittycad_modeling_cmds::{
self as kcmc, ModelingCmd, ok_response::OkModelingCmdResponse, shared::FileImportFormat,
websocket::OkWebSocketResponseData,
};
use kittycad_modeling_cmds::ModelingCmd;
use kittycad_modeling_cmds::ok_response::OkModelingCmdResponse;
use kittycad_modeling_cmds::shared::FileImportFormat;
use kittycad_modeling_cmds::websocket::OkWebSocketResponseData;
use kittycad_modeling_cmds::{self as kcmc};

use crate::cmd_kcl::write_deterministic_export;

Expand All @@ -19,7 +20,6 @@ use crate::cmd_kcl::write_deterministic_export;
/// # convert a step file to an obj file
/// zoo file convert --output-format=obj ./input.step ./
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdFile {
Expand Down Expand Up @@ -75,7 +75,6 @@ impl crate::cmd::Command for CmdFile {
/// # when converting from stdin, the original file type is required
/// cat my-obj.obj | zoo file convert --output-format=step --src-format=obj - output_dir
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdFileConvert {
Expand Down Expand Up @@ -183,7 +182,6 @@ impl crate::cmd::Command for CmdFileConvert {
/// # pass a file to snapshot from stdin
/// cat my-obj.obj | zoo file snapshot --output-format=png --src-format=obj - my-file.png
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdFileSnapshot {
Expand Down Expand Up @@ -611,7 +609,6 @@ impl crate::cmd::Command for CmdFileCenterOfMass {
/// # pass a file from stdin, the original file type is required
/// cat my-obj.obj | zoo file density - --src-format=obj -material-mass 212.2923 --material-mass-unit g --output-unit kg-m3
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdFileDensity {
Expand Down Expand Up @@ -695,7 +692,6 @@ impl crate::cmd::Command for CmdFileDensity {
/// # pass a file from stdin, the original file type is required
/// cat my-obj.obj | zoo file surface-area - --src-format=obj --output-unit m2
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdFileSurfaceArea {
Expand Down
12 changes: 8 additions & 4 deletions src/cmd_generate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use std::{fs, io::Write};

use anyhow::{Context, Result};
use clap::{Command, CommandFactory, Parser};
use std::fs;
use std::io::Write;

use anyhow::Context;
use anyhow::Result;
use clap::Command;
use clap::CommandFactory;
use clap::Parser;

/// Generate various documentation files for the `zoo` command line.
#[derive(Parser, Debug, Clone)]
Expand Down
34 changes: 22 additions & 12 deletions src/cmd_kcl.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
use std::{net::SocketAddr, path::Path, str::FromStr};
use std::net::SocketAddr;
use std::path::Path;
use std::str::FromStr;

use anyhow::Result;
use clap::Parser;
use image::{DynamicImage, ImageReader};
use kcl_lib::{ToLspRange, TypedPath, unit_conversion::ToKcmc};
use kcmc::{format::OutputFormat3d as OutputFormat, ok_response::OkModelingCmdResponse};
use image::DynamicImage;
use image::ImageReader;
use kcl_lib::ToLspRange;
use kcl_lib::TypedPath;
use kcl_lib::unit_conversion::ToKcmc;
use kcmc::format::OutputFormat3d as OutputFormat;
use kcmc::ok_response::OkModelingCmdResponse;
use kittycad::types as kt;
use kittycad_modeling_cmds::{self as kcmc, units::UnitLength, websocket::ModelingSessionData};
use kittycad_modeling_cmds::units::UnitLength;
use kittycad_modeling_cmds::websocket::ModelingSessionData;
use kittycad_modeling_cmds::{self as kcmc};
use url::Url;

use crate::{
iostreams::IoStreams,
kcl_error_fmt,
types::{CameraStyle, CameraView, FormatOutput},
};
use crate::iostreams::IoStreams;
use crate::kcl_error_fmt;
use crate::types::CameraStyle;
use crate::types::CameraView;
use crate::types::FormatOutput;

mod camera_angles;

Expand Down Expand Up @@ -213,7 +221,6 @@ impl crate::cmd::Command for CmdKclExport {
/// # Pass a file to format from stdin
/// cat my-obj.kcl | zoo kcl fmt -
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdKclFormat {
Expand Down Expand Up @@ -1986,7 +1993,10 @@ fn combine_quadrants(
output_path: &Path,
output_format: kcmc::ImageFormat,
) -> Result<()> {
use image::{GenericImage, GenericImageView, ImageBuffer, Rgba};
use image::GenericImage;
use image::GenericImageView;
use image::ImageBuffer;
use image::Rgba;
let (w, h) = top_left.dimensions();

// Sanity checks
Expand Down
4 changes: 2 additions & 2 deletions src/cmd_ml/cmd_kcl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::{Context, Result};
use anyhow::Context;
use anyhow::Result;
use clap::Parser;

/// KCL machine learning commands.
Expand Down Expand Up @@ -30,7 +31,6 @@ impl crate::cmd::Command for CmdKcl {
/// ```shell
/// zoo ml kcl copilot
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdKclCopilot {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd_open.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::Result;
use clap::Parser;
use parse_display::{Display, FromStr};
use parse_display::Display;
use parse_display::FromStr;

/// Shortcut to open the Zoo documentation or Account in your browser.
///
Expand All @@ -15,7 +16,6 @@ use parse_display::{Display, FromStr};
/// # open your Zoo account in your browser
/// zoo open account
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdOpen {
Expand Down
17 changes: 9 additions & 8 deletions src/cmd_org.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::{
collections::{HashMap, HashSet},
fs,
io::Write,
path::{Path, PathBuf},
};

use anyhow::{Context as _, Result};
use std::collections::HashMap;
use std::collections::HashSet;
use std::fs;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;

use anyhow::Context as _;
use anyhow::Result;
use clap::Parser;

use crate::types::FormatOutput;
Expand Down
22 changes: 12 additions & 10 deletions src/cmd_project.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::{
collections::HashSet,
future::Future,
io::Write,
path::{Path, PathBuf},
};

use anyhow::{Context as _, Result};
use std::collections::HashSet;
use std::future::Future;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;

use anyhow::Context as _;
use anyhow::Result;
use clap::Parser;

use crate::types::FormatOutput;
Expand Down Expand Up @@ -588,9 +588,11 @@ mod tests {
command: &CmdProject,
responses: Vec<Option<(u16, String)>>,
) -> (Result<()>, String, Vec<String>) {
use tokio::io::{AsyncBufReadExt, AsyncWriteExt};
use tokio::io::AsyncBufReadExt;
use tokio::io::AsyncWriteExt;

use crate::{cmd::Command, config::Config};
use crate::cmd::Command;
use crate::config::Config;

let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
let host = format!("http://{}/custom-api", listener.local_addr().unwrap());
Expand Down
1 change: 0 additions & 1 deletion src/cmd_say.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use clap::Parser;
/// zoo say hello!
/// zoo say Hello World!
/// ```
///
#[derive(Parser, Debug, Clone)]
#[clap(verbatim_doc_comment)]
pub struct CmdSay {
Expand Down
Loading
Loading