Skip to content

Commit 456e467

Browse files
committed
Add CLI help
1 parent ce08e20 commit 456e467

File tree

1 file changed

+14
-10
lines changed
  • cli/src/main/kotlin/com/jdamcd/arrivals/cli

1 file changed

+14
-10
lines changed

cli/src/main/kotlin/com/jdamcd/arrivals/cli/Cli.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.github.ajalt.clikt.command.main
55
import com.github.ajalt.clikt.parameters.groups.OptionGroup
66
import com.github.ajalt.clikt.parameters.groups.defaultByName
77
import com.github.ajalt.clikt.parameters.groups.groupChoice
8+
import com.github.ajalt.clikt.parameters.options.help
89
import com.github.ajalt.clikt.parameters.options.option
910
import com.github.ajalt.clikt.parameters.types.choice
1011
import com.jdamcd.arrivals.Arrivals
@@ -29,6 +30,7 @@ private class Cli :
2930
private val settings: Settings by inject()
3031

3132
val mode by option()
33+
.help("Transit feed type")
3234
.groupChoice("tfl" to Tfl(), "gtfs" to Gtfs())
3335
.defaultByName("tfl")
3436

@@ -50,17 +52,17 @@ private class Cli :
5052
is Tfl -> {
5153
val mode = mode as Tfl
5254
settings.mode = SettingsConfig.MODE_TFL
53-
mode.stationId?.let { settings.tflStopId = it }
55+
mode.station?.let { settings.tflStopId = it }
5456
mode.platform?.let { settings.tflPlatform = it }
5557
mode.direction?.let { settings.tflDirection = it }
5658
}
5759

5860
is Gtfs -> {
5961
val mode = mode as Gtfs
6062
settings.mode = SettingsConfig.MODE_GTFS
61-
mode.stopId?.let { settings.gtfsStop = it }
62-
mode.realtimeUrl?.let { settings.gtfsRealtime = it }
63-
mode.scheduleUrl?.let { settings.gtfsSchedule = it }
63+
mode.stop?.let { settings.gtfsStop = it }
64+
mode.realtime?.let { settings.gtfsRealtime = it }
65+
mode.schedule?.let { settings.gtfsSchedule = it }
6466
}
6567
}
6668
}
@@ -69,13 +71,15 @@ private class Cli :
6971
private sealed class TransitProvider(name: String) : OptionGroup(name)
7072

7173
private class Tfl : TransitProvider("TfL options") {
72-
val stationId by option()
73-
val platform by option()
74-
val direction by option().choice("inbound", "outbound", "all")
74+
val station by option().help("Station ID")
75+
val platform by option().help("Platform filter (optional)")
76+
val direction by option()
77+
.choice("inbound", "outbound", "all")
78+
.help("Direction filter (optional)")
7579
}
7680

7781
private class Gtfs : TransitProvider("GTFS options") {
78-
val stopId by option()
79-
val realtimeUrl by option()
80-
val scheduleUrl by option()
82+
val stop by option().help("Stop ID")
83+
val realtime by option().help("GTFS-RT feed URL")
84+
val schedule by option().help("GTFS schedule URL")
8185
}

0 commit comments

Comments
 (0)