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.lockdiffbeforeafterboth7 packageslockfile v7
Might be heavy and slow!
crane
480dff0github.com/ipetkov/crane↘ 1↖ 1sourcegithub:ipetkov/cranechecksumsha256-dIubLa56W9sNNz0e8jGxrX3CAkPXsq7snuFA/Ie6dn8=depends onused bydefault
da67096github.com/nix-systems/default↘ 0↖ 1sourcegithub:nix-systems/defaultchecksumsha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=used byflake-utils
b1d9ab7github.com/numtide/flake-utils↘ 1↖ 2sourcegithub:numtide/flake-utilschecksumsha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=depends onused bynixpkgs
ab5efd0github.com/nixos/nixpkgs↘ 0↖ 3sourcegithub:nixos/nixpkgs/masterchecksumsha256-Jrn+/CdB/d2hUqduYQdTwGJYDAdaR5cAdlxnq+yEtXI=root
workspace↘ 5↖ 0rust-overlay
ab69b67github.com/oxalica/rust-overlay↘ 2↖ 1sourcegithub:oxalica/rust-overlaychecksumsha256-4gVhbC+NjSQ4c6cJvJGNCI1oTcD+8jRRNAnOF9faGCE=depends onused by
7 packageslockfile v7
Might be heavy and slow!
crane
ae1453fgithub.com/ipetkov/crane↘ 1↖ 1sourcegithub:ipetkov/cranechecksumsha256-K8O2KQEbA+NIAc8BDsWV6QKqU3i9M+YTUi4zzmLRy1s=depends onused bydefault
da67096github.com/nix-systems/default↘ 0↖ 1sourcegithub:nix-systems/defaultchecksumsha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=used byflake-utils
b1d9ab7github.com/numtide/flake-utils↘ 1↖ 2sourcegithub:numtide/flake-utilschecksumsha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=depends onused bynixpkgs
73bff84github.com/nixos/nixpkgs↘ 0↖ 3sourcegithub:nixos/nixpkgs/masterchecksumsha256-hkD00+n53WNZ4k8hqIbekl5WGDsmb5urhAuDh5XYjyc=root
workspace↘ 5↖ 0rust-overlay
b46857agithub.com/oxalica/rust-overlay↘ 2↖ 1sourcegithub:oxalica/rust-overlaychecksumsha256-QhlS52cEQyx+iVcgrEoCnEEpWUA6uLdmeLRxk935inI=depends onused by
pkgs/fleet.nixdiffbeforeafterboth--- a/pkgs/fleet.nix
+++ b/pkgs/fleet.nix
@@ -1,4 +1,7 @@
-{craneLib}:
+{
+ craneLib,
+ installShellFiles,
+}:
craneLib.buildPackage rec {
pname = "fleet";
@@ -7,10 +10,12 @@
cargoExtraArgs = "--locked -p ${pname}";
+ nativeBuildInputs = [installShellFiles];
+
postInstall = ''
for shell in bash fish zsh; do
installShellCompletion --cmd fleet \
- --$shell <($out/bin/fleet complete --shell $shell --print)
+ --$shell <($out/bin/fleet complete --shell $shell)
done
'';
}