difftreelog
fix(fleet-cmd) include the required package for tab completions (#5)
in: trunk
* fix(fleet-cmd): include the required package for tab completions * style(fleet-cmd): reformat automatically
9 files changed
cmds/fleet/src/better_nix_eval.rsdiffbeforeafterboth1//! Wrapper around nix repl, which allows to work on nix code, without relying on1//! Wrapper around nix repl, which allows to work on nix code, without relying on2//! nix libexpr. I mean, nix libexpr is good, but until it has no C bindings, this is the royal PITA.2//! nix libexpr. I mean, nix libexpr is good, but until it has no C bindings, this is the royal PITA.334use std::collections::HashMap;4use std::{5use std::ffi::{OsStr, OsString};5 collections::HashMap,6use std::fmt::{self, Display};6 ffi::{OsStr, OsString},7 fmt::{self, Display},7use std::path::PathBuf;8 path::PathBuf,8use std::process::Stdio;9 process::Stdio,9use std::sync::{Arc, OnceLock};10 sync::{Arc, OnceLock},11};101211use anyhow::{anyhow, bail, ensure, Context, Result};13use anyhow::{anyhow, bail, ensure, Context, Result};12use better_command::{ClonableHandler, Handler, NixHandler, NoopHandler};14use better_command::{ClonableHandler, Handler, NixHandler, NoopHandler};13use futures::StreamExt;15use futures::StreamExt;14use itertools::Itertools;16use itertools::Itertools;15use serde::de::DeserializeOwned;16use serde::{Deserialize, Serialize};17use serde::{de::DeserializeOwned, Deserialize, Serialize};17use tokio::io::AsyncWriteExt;18use tokio::process::{ChildStderr, ChildStdin, ChildStdout, Command};18use tokio::{19use tokio::select;19 io::AsyncWriteExt,20use tokio::sync::{mpsc, oneshot, Mutex};20 process::{ChildStderr, ChildStdin, ChildStdout, Command},21 select,22 sync::{mpsc, oneshot, Mutex},23};21use tracing::{debug, error, warn, Level};24use tracing::{debug, error, warn, Level};222523cmds/fleet/src/cmds/build_systems.rsdiffbeforeafterboth1use std::os::unix::fs::symlink;2use std::path::PathBuf;3use std::{env::current_dir, time::Duration};1use std::{env::current_dir, os::unix::fs::symlink, path::PathBuf, time::Duration};425use crate::command::MyCommand;6use crate::host::{Config, ConfigHost};7use anyhow::{anyhow, Result};3use anyhow::{anyhow, Result};8use clap::{Parser, ValueEnum};4use clap::{Parser, ValueEnum};9use itertools::Itertools as _;5use itertools::Itertools as _;10use nix_eval::nix_go;6use nix_eval::nix_go;11use tokio::{task::LocalSet, time::sleep};7use tokio::{task::LocalSet, time::sleep};12use tracing::{error, field, info, info_span, warn, Instrument};8use tracing::{error, field, info, info_span, warn, Instrument};910use crate::{11 command::MyCommand,12 host::{Config, ConfigHost},13};131414#[derive(Parser)]15#[derive(Parser)]15pub struct Deploy {16pub struct Deploy {cmds/fleet/src/cmds/info.rsdiffbeforeafterboth1use std::collections::BTreeSet;1use std::collections::BTreeSet;223use crate::host::Config;4use anyhow::{ensure, Result};3use anyhow::{ensure, Result};5use clap::Parser;4use clap::Parser;6use nix_eval::nix_go_json;5use nix_eval::nix_go_json;67use crate::host::Config;788#[derive(Parser)]9#[derive(Parser)]9pub struct Info {10pub struct Info {cmds/fleet/src/cmds/mod.rsdiffbeforeafterboth1pub mod build_systems;1pub mod build_systems;2pub mod info;2pub mod complete;3pub mod secrets;3pub mod info;4pub mod complete;4pub mod secrets;55cmds/fleet/src/extra_args.rsdiffbeforeafterboth1use anyhow::anyhow;2use anyhow::Result;3use std::ffi::{OsStr, OsString};1use std::ffi::{OsStr, OsString};23use anyhow::{anyhow, Result};445pub fn parse_os(os: &OsStr) -> Result<Vec<OsString>> {5pub fn parse_os(os: &OsStr) -> Result<Vec<OsString>> {6 Ok(shlex::bytes::split(os.as_encoded_bytes())6 Ok(shlex::bytes::split(os.as_encoded_bytes())cmds/fleet/src/keys.rsdiffbeforeafterboth1use std::str::FromStr;1use std::str::FromStr;223use crate::host::Config;4use age::Recipient;3use age::Recipient;5use anyhow::{anyhow, Result};4use anyhow::{anyhow, Result};6use futures::{StreamExt, TryStreamExt};5use futures::{StreamExt, TryStreamExt};7use itertools::Itertools;6use itertools::Itertools;8use tracing::warn;7use tracing::warn;89use crate::host::Config;91010impl Config {11impl Config {11 pub fn cached_key(&self, host: &str) -> Option<String> {12 pub fn cached_key(&self, host: &str) -> Option<String> {cmds/fleet/src/main.rsdiffbeforeafterboth175 reg.init();175 reg.init();176}176}177178fn main() -> ExitCode {179 let opts = RootOpts::parse();180 if let Opts::Complete(c) = &opts.command {181 c.run(RootOpts::command());182 return ExitCode::SUCCESS;183 }184185 setup_logging();186 async_main(opts)187}177188178#[tokio::main]189#[tokio::main]179async fn main() -> ExitCode {190async fn async_main(opts: RootOpts) -> ExitCode {180 setup_logging();181 if let Err(e) = main_real().await {191 if let Err(e) = main_real(opts).await {182 // If I remove this line, the next error!() line gets eaten.192 // If I remove this line, the next error!() line gets eaten.183 // This is a bug in indicatif, it needs to be fixed193 // This is a bug in indicatif, it needs to be fixed184 #[cfg(feature = "indicatif")]194 #[cfg(feature = "indicatif")]189 ExitCode::SUCCESS199 ExitCode::SUCCESS190}200}191201192async fn main_real() -> Result<()> {202async fn main_real(opts: RootOpts) -> Result<()> {193 nix_eval::init_tokio();203 nix_eval::init_tokio();194204195 let nix_args = std::env::var_os("NIX_ARGS")205 let nix_args = std::env::var_os("NIX_ARGS")196 .map(|a| extra_args::parse_os(&a))206 .map(|a| extra_args::parse_os(&a))197 .transpose()?207 .transpose()?198 .unwrap_or_default();208 .unwrap_or_default();199 let opts = RootOpts::parse();200 let config = opts.fleet_opts.build(nix_args).await?;209 let config = opts.fleet_opts.build(nix_args).await?;201210202 match run_command(&config, opts.command).await {211 match run_command(&config, opts.command).await {flake.lockdiffbeforeafterboth7 ]7 ]8 },8 },9 "locked": {9 "locked": {10 "lastModified": 1717025063,10 "lastModified": 1717290123,11 "narHash": "sha256-dIubLa56W9sNNz0e8jGxrX3CAkPXsq7snuFA/Ie6dn8=",11 "narHash": "sha256-K8O2KQEbA+NIAc8BDsWV6QKqU3i9M+YTUi4zzmLRy1s=",12 "owner": "ipetkov",12 "owner": "ipetkov",13 "repo": "crane",13 "repo": "crane",14 "rev": "480dff0be03dac0e51a8dfc26e882b0d123a450e",14 "rev": "ae1453ffd0f8f684e863685c317a953317db2b79",15 "type": "github"15 "type": "github"16 },16 },17 "original": {17 "original": {40 },40 },41 "nixpkgs": {41 "nixpkgs": {42 "locked": {42 "locked": {43 "lastModified": 1717282945,43 "lastModified": 1717336170,44 "narHash": "sha256-Jrn+/CdB/d2hUqduYQdTwGJYDAdaR5cAdlxnq+yEtXI=",44 "narHash": "sha256-hkD00+n53WNZ4k8hqIbekl5WGDsmb5urhAuDh5XYjyc=",45 "owner": "nixos",45 "owner": "nixos",46 "repo": "nixpkgs",46 "repo": "nixpkgs",47 "rev": "ab5efd0f3c62dd3b75d21d0de1dd63efc76be5d8",47 "rev": "73bff846b4e8d0c8156c6fc726bf623fe3f3845c",48 "type": "github"48 "type": "github"49 },49 },50 "original": {50 "original": {56 },56 },57 "nixpkgs-stable-for-tests": {57 "nixpkgs-stable-for-tests": {58 "locked": {58 "locked": {59 "lastModified": 1716991068,59 "lastModified": 1717159533,60 "narHash": "sha256-Av0UWCCiIGJxsZ6TFc+OiKCJNqwoxMNVYDBChmhjNpo=",60 "narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=",61 "owner": "nixos",61 "owner": "nixos",62 "repo": "nixpkgs",62 "repo": "nixpkgs",63 "rev": "25cf937a30bf0801447f6bf544fc7486c6309234",63 "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446",64 "type": "github"64 "type": "github"65 },65 },66 "original": {66 "original": {89 ]89 ]90 },90 },91 "locked": {91 "locked": {92 "lastModified": 1717208326,92 "lastModified": 1717294752,93 "narHash": "sha256-4gVhbC+NjSQ4c6cJvJGNCI1oTcD+8jRRNAnOF9faGCE=",93 "narHash": "sha256-QhlS52cEQyx+iVcgrEoCnEEpWUA6uLdmeLRxk935inI=",94 "owner": "oxalica",94 "owner": "oxalica",95 "repo": "rust-overlay",95 "repo": "rust-overlay",96 "rev": "ab69b67fac9a96709fbef0b899db308ca714a120",96 "rev": "b46857a406d207a1de74e792ef3b83e800c30e08",97 "type": "github"97 "type": "github"98 },98 },99 "original": {99 "original": {pkgs/fleet.nixdiffbeforeafterboth1{craneLib}:1{2 craneLib,3 installShellFiles,4}:2craneLib.buildPackage rec {5craneLib.buildPackage rec {3 pname = "fleet";6 pname = "fleet";7108 cargoExtraArgs = "--locked -p ${pname}";11 cargoExtraArgs = "--locked -p ${pname}";1213 nativeBuildInputs = [installShellFiles];91410 postInstall = ''15 postInstall = ''11 for shell in bash fish zsh; do16 for shell in bash fish zsh; do12 installShellCompletion --cmd fleet \17 installShellCompletion --cmd fleet \13 --$shell <($out/bin/fleet complete --shell $shell --print)18 --$shell <($out/bin/fleet complete --shell $shell)14 done19 done15 '';20 '';16}21}1722