Skip to content

Commit 8f77ce3

Browse files
committed
added optional argument for volume path
1 parent 3ce5e17 commit 8f77ce3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

diskspace/main.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ struct DiskSpace : ParsableCommand {
3131
@Flag(name: .shortAndLong,
3232
help: "Print only the value of the total Capacity")
3333
var total = false
34-
34+
35+
@Argument var volumePath = "/"
36+
3537
func printValue(value int: Int, label: String? = nil) {
3638
printValue(value: Int64(int), label: label)
3739
}
@@ -55,7 +57,7 @@ struct DiskSpace : ParsableCommand {
5557
func run() {
5658
let showAll = !(available || important || opportunistic || total)
5759

58-
let systemVolume = URL(fileURLWithPath:"/")
60+
let systemVolume = URL(fileURLWithPath: volumePath)
5961
do {
6062
let values = try systemVolume.resourceValues(forKeys: [.volumeAvailableCapacityKey,.volumeAvailableCapacityForImportantUsageKey, .volumeAvailableCapacityForOpportunisticUsageKey, .volumeTotalCapacityKey])
6163
if let availableCapacity = values.volumeAvailableCapacity {

0 commit comments

Comments
 (0)