Skip to content

Commit a786d54

Browse files
committed
fix missing -m flag
1 parent 6738b37 commit a786d54

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/uu/df/locales/en-US.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ df-help-total = produce a grand total
1717
df-help-human-readable = print sizes in human readable format (e.g., 1K 234M 2G)
1818
df-help-si = likewise, but use powers of 1000 not 1024
1919
df-help-inodes = list inode information instead of block usage
20+
df-help-mega = like --block-size=1M
2021
df-help-kilo = like --block-size=1K
2122
df-help-local = limit listing to local file systems
2223
df-help-no-sync = do not invoke sync before getting usage info (default)

src/uu/df/src/blocks.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,22 @@ pub(crate) fn read_block_size(matches: &ArgMatches) -> Result<BlockSize, ParseSi
176176
} else {
177177
Err(ParseSizeError::ParseFailure(format!("{}", s.quote())))
178178
}
179+
} else if matches.get_flag("mega") {
180+
Ok(BlockSize::Bytes(1024 * 1024))
181+
} else if matches.get_flag("kilo") {
182+
Ok(BlockSize::Bytes(1024))
179183
} else if matches.get_flag(OPT_PORTABILITY) {
180184
Ok(BlockSize::default())
181185
} else if let Some(bytes) =
182186
parse_block_size::block_size_from_env(&["DF_BLOCK_SIZE", "BLOCK_SIZE", "BLOCKSIZE"]).found()
183187
{
184-
Ok(BlockSize::Bytes(bytes))
188+
Ok(BlockSize::Bytes(bytes))
185189
} else {
186190
Ok(BlockSize::default())
187191
}
188192
}
189193

194+
190195
impl fmt::Display for BlockSize {
191196
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
192197
match self {

src/uu/df/src/df.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static OPT_TOTAL: &str = "total";
3838
static OPT_HUMAN_READABLE_BINARY: &str = "human-readable-binary";
3939
static OPT_HUMAN_READABLE_DECIMAL: &str = "human-readable-decimal";
4040
static OPT_INODES: &str = "inodes";
41+
static OPT_MEGA: &str = "mega";
4142
static OPT_KILO: &str = "kilo";
4243
static OPT_LOCAL: &str = "local";
4344
static OPT_NO_SYNC: &str = "no-sync";
@@ -517,7 +518,7 @@ pub fn uu_app() -> Command {
517518
.short('B')
518519
.long("block-size")
519520
.value_name("SIZE")
520-
.overrides_with_all([OPT_KILO, OPT_BLOCKSIZE])
521+
.overrides_with_all([OPT_KILO, OPT_BLOCKSIZE, OPT_MEGA])
521522
.help(translate!("df-help-block-size")),
522523
)
523524
.arg(
@@ -551,11 +552,18 @@ pub fn uu_app() -> Command {
551552
.help(translate!("df-help-inodes"))
552553
.action(ArgAction::SetTrue),
553554
)
555+
.arg(
556+
Arg::new(OPT_MEGA)
557+
.short('m')
558+
.help(translate!("df-help-mega"))
559+
.overrides_with_all([OPT_BLOCKSIZE, OPT_KILO, OPT_MEGA])
560+
.action(ArgAction::SetTrue),
561+
)
554562
.arg(
555563
Arg::new(OPT_KILO)
556564
.short('k')
557565
.help(translate!("df-help-kilo"))
558-
.overrides_with_all([OPT_BLOCKSIZE, OPT_KILO])
566+
.overrides_with_all([OPT_BLOCKSIZE, OPT_KILO, OPT_MEGA])
559567
.action(ArgAction::SetTrue),
560568
)
561569
.arg(

0 commit comments

Comments
 (0)