commit 50d64a827851c912d8e309170ceca3209ab971c9
parent 9c781ab7d16115e5882c16152f05315834930c94
Author: triesap <tyson@radroots.org>
Date: Fri, 26 Jun 2026 22:49:22 +0000
cli: accept negative farm coordinates
Allow separated negative numeric values for farm location latitude and longitude flags.
Add parser coverage for the Victoria longitude command shape so the normal --lng -123... spelling remains supported.
Diffstat:
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/src/cli/farm.rs b/src/cli/farm.rs
@@ -87,9 +87,9 @@ pub enum FarmLocationCommand {
#[derive(Debug, Clone, Args)]
pub struct FarmLocationSetArgs {
- #[arg(long)]
+ #[arg(long, allow_negative_numbers = true)]
pub lat: Option<f64>,
- #[arg(long)]
+ #[arg(long, allow_negative_numbers = true)]
pub lng: Option<f64>,
#[arg(long = "farm-d-tag")]
pub farm_d_tag: Option<String>,
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
@@ -299,8 +299,9 @@ mod tests {
use clap::{CommandFactory, Parser};
use super::{
- AccountCommand, FarmCommand, ListingCommand, TargetCliArgs, TargetOutputFormat,
- TradeCommand, TradeRevisionCommand, ValidationCommand, ValidationReceiptCommand,
+ AccountCommand, FarmCommand, FarmLocationCommand, ListingCommand, TargetCliArgs,
+ TargetOutputFormat, TradeCommand, TradeRevisionCommand, ValidationCommand,
+ ValidationReceiptCommand,
};
use crate::registry::OPERATION_REGISTRY;
@@ -432,6 +433,34 @@ mod tests {
}
#[test]
+ fn target_parser_accepts_negative_farm_location_coordinates() {
+ let parsed = TargetCliArgs::try_parse_from([
+ "radroots",
+ "farm",
+ "location",
+ "set",
+ "--lat",
+ "48.429456",
+ "--lng",
+ "-123.349786",
+ ])
+ .expect("target args parse");
+
+ assert_eq!(parsed.command.operation_id(), "farm.location.set");
+ let crate::cli::TargetCommand::Farm(farm) = parsed.command else {
+ panic!("expected farm command")
+ };
+ let FarmCommand::Location(location) = farm.command else {
+ panic!("expected farm location command")
+ };
+ let FarmLocationCommand::Set(args) = location.command else {
+ panic!("expected farm location set command")
+ };
+ assert_eq!(args.lat, Some(48.429456));
+ assert_eq!(args.lng, Some(-123.349786));
+ }
+
+ #[test]
fn target_parser_accepts_listing_rebind_inputs() {
let parsed = TargetCliArgs::try_parse_from([
"radroots",