Skip to content

Commit

Permalink
feat: latest.rb can return just the version num
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Nov 13, 2024
1 parent 81a1441 commit 6010b04
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions util/latest.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/usr/bin/env ruby

unless ARGV.length == 2
$stderr.puts """USAGE: #{$0} [SUBDIRECTORY] [CONFIG_BASENAME]
- obtain the latest version of the config file with basename [CONFIG] from
if ARGV.length < 2
$stderr.puts """USAGE: #{$0} [SUBDIRECTORY] [CONFIG_BASENAME] [OUTPUT]
- obtain the latest version of the config file with basename [CONFIG] from
[SUBDIRECTORY], assuming [SUBDIRECTORY] contains subdirectories of tag names
- tag names that are not semantic version numbers, such as `dev`, are ignored
- [OUTPUT] may be either:
'file': return the file name (default behavior)
'version': return just the version number
"""
exit 2
end

subdir, config = ARGV
subdir, config = ARGV[0..1]
output = ARGV.length >= 3 ? ARGV[2] : 'file'
unless Dir.exist? subdir
$stderr.puts "ERROR: subdirectory '#{subdir}' does not exist"
exit 1
Expand Down Expand Up @@ -48,4 +52,12 @@
end

# return the latest version of that config file
puts configFiles.first
case output
when 'file'
puts configFiles.first
when 'version'
puts tagdirs.first
else
$stderr.puts "ERROR: unknown [OUTPUT] '#{output}'"
exit 1
end

0 comments on commit 6010b04

Please sign in to comment.