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.rsdiffbeforeafterboth--- a/cmds/fleet/src/better_nix_eval.rs
+++ b/cmds/fleet/src/better_nix_eval.rs
@@ -1,25 +1,24 @@
//! Wrapper around nix repl, which allows to work on nix code, without relying on
//! nix libexpr. I mean, nix libexpr is good, but until it has no C bindings, this is the royal PITA.
-use std::collections::HashMap;
-use std::ffi::{OsStr, OsString};
-use std::fmt::{self, Display};
-use std::path::PathBuf;
-use std::process::Stdio;
-use std::sync::{Arc, OnceLock};
+use std::{
+ collections::HashMap,
+ ffi::{OsStr, OsString},
+ fmt::{self, Display},
+ path::PathBuf,
+ process::Stdio,
+ sync::{Arc, OnceLock},
+};
use anyhow::{anyhow, bail, ensure, Context, Result};
use better_command::{ClonableHandler, Handler, NixHandler, NoopHandler};
use futures::StreamExt;
use itertools::Itertools;
-use serde::de::DeserializeOwned;
-use serde::{Deserialize, Serialize};
-use tokio::io::AsyncWriteExt;
-use tokio::process::{ChildStderr, ChildStdin, ChildStdout, Command};
-use tokio::select;
-use tokio::sync::{mpsc, oneshot, Mutex};
+use serde::{de::DeserializeOwned, Deserialize, Serialize};
+use tokio::{
+ io::AsyncWriteExt,
+ process::{ChildStderr, ChildStdin, ChildStdout, Command},
+ select,
+ sync::{mpsc, oneshot, Mutex},
+};
use tracing::{debug, error, warn, Level};
-
-
-
-
cmds/fleet/src/cmds/build_systems.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/build_systems.rs
+++ b/cmds/fleet/src/cmds/build_systems.rs
@@ -1,9 +1,5 @@
-use std::os::unix::fs::symlink;
-use std::path::PathBuf;
-use std::{env::current_dir, time::Duration};
+use std::{env::current_dir, os::unix::fs::symlink, path::PathBuf, time::Duration};
-use crate::command::MyCommand;
-use crate::host::{Config, ConfigHost};
use anyhow::{anyhow, Result};
use clap::{Parser, ValueEnum};
use itertools::Itertools as _;
@@ -11,6 +7,11 @@
use tokio::{task::LocalSet, time::sleep};
use tracing::{error, field, info, info_span, warn, Instrument};
+use crate::{
+ command::MyCommand,
+ host::{Config, ConfigHost},
+};
+
#[derive(Parser)]
pub struct Deploy {
/// Disable automatic rollback
cmds/fleet/src/cmds/info.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/info.rs
+++ b/cmds/fleet/src/cmds/info.rs
@@ -1,10 +1,11 @@
use std::collections::BTreeSet;
-use crate::host::Config;
use anyhow::{ensure, Result};
use clap::Parser;
use nix_eval::nix_go_json;
+use crate::host::Config;
+
#[derive(Parser)]
pub struct Info {
#[clap(long)]
cmds/fleet/src/cmds/mod.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/mod.rs
+++ b/cmds/fleet/src/cmds/mod.rs
@@ -1,4 +1,4 @@
pub mod build_systems;
+pub mod complete;
pub mod info;
pub mod secrets;
-pub mod complete;
cmds/fleet/src/extra_args.rsdiffbeforeafterboth--- a/cmds/fleet/src/extra_args.rs
+++ b/cmds/fleet/src/extra_args.rs
@@ -1,7 +1,7 @@
-use anyhow::anyhow;
-use anyhow::Result;
use std::ffi::{OsStr, OsString};
+use anyhow::{anyhow, Result};
+
pub fn parse_os(os: &OsStr) -> Result<Vec<OsString>> {
Ok(shlex::bytes::split(os.as_encoded_bytes())
.ok_or_else(|| anyhow!("invalid arguments"))?
cmds/fleet/src/keys.rsdiffbeforeafterboth--- a/cmds/fleet/src/keys.rs
+++ b/cmds/fleet/src/keys.rs
@@ -1,12 +1,13 @@
use std::str::FromStr;
-use crate::host::Config;
use age::Recipient;
use anyhow::{anyhow, Result};
use futures::{StreamExt, TryStreamExt};
use itertools::Itertools;
use tracing::warn;
+use crate::host::Config;
+
impl Config {
pub fn cached_key(&self, host: &str) -> Option<String> {
let data = self.data();
cmds/fleet/src/main.rsdiffbeforeafterboth--- a/cmds/fleet/src/main.rs
+++ b/cmds/fleet/src/main.rs
@@ -175,10 +175,20 @@
reg.init();
}
-#[tokio::main]
-async fn main() -> ExitCode {
+fn main() -> ExitCode {
+ let opts = RootOpts::parse();
+ if let Opts::Complete(c) = &opts.command {
+ c.run(RootOpts::command());
+ return ExitCode::SUCCESS;
+ }
+
setup_logging();
- if let Err(e) = main_real().await {
+ async_main(opts)
+}
+
+#[tokio::main]
+async fn async_main(opts: RootOpts) -> ExitCode {
+ if let Err(e) = main_real(opts).await {
// If I remove this line, the next error!() line gets eaten.
// This is a bug in indicatif, it needs to be fixed
#[cfg(feature = "indicatif")]
@@ -189,14 +199,13 @@
ExitCode::SUCCESS
}
-async fn main_real() -> Result<()> {
+async fn main_real(opts: RootOpts) -> Result<()> {
nix_eval::init_tokio();
let nix_args = std::env::var_os("NIX_ARGS")
.map(|a| extra_args::parse_os(&a))
.transpose()?
.unwrap_or_default();
- let opts = RootOpts::parse();
let config = opts.fleet_opts.build(nix_args).await?;
match run_command(&config, opts.command).await {
flake.lockdiffbeforeafterboth--- a/flake.lock
+++ b/flake.lock
@@ -7,11 +7,11 @@
]
},
"locked": {
- "lastModified": 1717025063,
- "narHash": "sha256-dIubLa56W9sNNz0e8jGxrX3CAkPXsq7snuFA/Ie6dn8=",
+ "lastModified": 1717290123,
+ "narHash": "sha256-K8O2KQEbA+NIAc8BDsWV6QKqU3i9M+YTUi4zzmLRy1s=",
"owner": "ipetkov",
"repo": "crane",
- "rev": "480dff0be03dac0e51a8dfc26e882b0d123a450e",
+ "rev": "ae1453ffd0f8f684e863685c317a953317db2b79",
"type": "github"
},
"original": {
@@ -40,11 +40,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1717282945,
- "narHash": "sha256-Jrn+/CdB/d2hUqduYQdTwGJYDAdaR5cAdlxnq+yEtXI=",
+ "lastModified": 1717336170,
+ "narHash": "sha256-hkD00+n53WNZ4k8hqIbekl5WGDsmb5urhAuDh5XYjyc=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "ab5efd0f3c62dd3b75d21d0de1dd63efc76be5d8",
+ "rev": "73bff846b4e8d0c8156c6fc726bf623fe3f3845c",
"type": "github"
},
"original": {
@@ -56,11 +56,11 @@
},
"nixpkgs-stable-for-tests": {
"locked": {
- "lastModified": 1716991068,
- "narHash": "sha256-Av0UWCCiIGJxsZ6TFc+OiKCJNqwoxMNVYDBChmhjNpo=",
+ "lastModified": 1717159533,
+ "narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "25cf937a30bf0801447f6bf544fc7486c6309234",
+ "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446",
"type": "github"
},
"original": {
@@ -89,11 +89,11 @@
]
},
"locked": {
- "lastModified": 1717208326,
- "narHash": "sha256-4gVhbC+NjSQ4c6cJvJGNCI1oTcD+8jRRNAnOF9faGCE=",
+ "lastModified": 1717294752,
+ "narHash": "sha256-QhlS52cEQyx+iVcgrEoCnEEpWUA6uLdmeLRxk935inI=",
"owner": "oxalica",
"repo": "rust-overlay",
- "rev": "ab69b67fac9a96709fbef0b899db308ca714a120",
+ "rev": "b46857a406d207a1de74e792ef3b83e800c30e08",
"type": "github"
},
"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