From 87465de035833e2229a31b0d7e740d4a065a6c13 Mon Sep 17 00:00:00 2001 From: bill-auger Date: Tue, 10 Dec 2019 01:28:45 -0500 Subject: add group filter to meta-cat --- bin/meta-cat | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/meta-cat b/bin/meta-cat index 5e7097e..381a0a3 100755 --- a/bin/meta-cat +++ b/bin/meta-cat @@ -1,7 +1,8 @@ #!/usr/bin/env ruby # Usage: meta-cat -# Copyright 2016 Luke Shumaker . +# Copyright 2016 Luke Shumaker +# Copyright 2019 bill-auger # # This is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -17,6 +18,20 @@ # License along with this manual; if not, see # . + load "#{File.dirname(__FILE__)}/common.rb" -print load_all_users.to_yaml + +users = load_all_users + +if ARGV.size == 2 && ARGV[0] == '--group' + users.each do | user | + group = ARGV[1] + uid = user[0] + user_data = user[1] + + print "#{uid},#{user_data['username']}\n" if user_data['groups'].include? group + end +else + print users.to_yaml +end -- cgit v1.2.2