Skip to content

Commit

Permalink
Add chords subcommand listing all suported chord types and symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
noeddl committed Dec 5, 2021
1 parent 6c5d569 commit 47677f8
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use itertools::Itertools;
use lazy_static::lazy_static;
use structopt::StructOpt;
use ukebox::{
Chord, ChordChart, ChordSequence, FretID, FretPattern, Semitones, Tuning, Voicing,
Chord, ChordChart, ChordSequence, ChordType, FretID, FretPattern, Semitones, Tuning, Voicing,
VoicingConfig, VoicingGraph,
};

Expand Down Expand Up @@ -33,14 +34,23 @@ struct Ukebox {

#[derive(StructOpt)]
enum Subcommand {
/// List all supported chord types and symbols
Chords {},
/// Chord chart lookup
///
/// Enter note names as capital letters A - G.
/// Add '#' for sharp notes, e.g. D#.
/// Add 'b' for flat notes, e.g. Eb.
///
/// Run "ukebox chords" to get a list of the chord types and symbols currently supported.
#[structopt(verbatim_doc_comment)]
Chart {
/// Print out all voicings of <chord> that fulfill the given conditions
#[structopt(short, long)]
all: bool,
#[structopt(flatten)]
voicing_opts: VoicingOpts,
/// Name of the chord to be shown
/// Name of the chord to be shown
#[structopt(value_name = "CHORD")]
chord: Chord,
},
Expand Down Expand Up @@ -106,6 +116,15 @@ fn main() {
let tuning = args.tuning;

match args.cmd {
Subcommand::Chords {} => {
println!("Supported chord types and symbols\n");
println!("The root note C is used as an example.\n");

for chord_type in ChordType::values() {
let symbols = chord_type.symbols().map(|s| format!("C{}", s)).join(", ");
println!("C {} - {}", chord_type, symbols);
}
}
Subcommand::Chart {
all,
voicing_opts,
Expand Down

0 comments on commit 47677f8

Please sign in to comment.