[PATCH configure 2/2] added usage to aeolus-restart-services
Hugh Brock
hbrock at redhat.com
Wed Dec 14 18:52:46 UTC 2011
On Wed, Dec 14, 2011 at 11:32:28AM -0500, Jason Guiditta wrote:
> On 14/12/11 12:58 +0100, mzatko at redhat.com wrote:
> >From: Maros Zatko <mzatko at redhat.com>
> >
> >---
> >bin/aeolus-restart-services | 12 ++++++++++++
> >1 files changed, 12 insertions(+), 0 deletions(-)
> >
> >diff --git a/bin/aeolus-restart-services b/bin/aeolus-restart-services
> >index dd85fcf..6c44295 100755
> >--- a/bin/aeolus-restart-services
> >+++ b/bin/aeolus-restart-services
> >@@ -14,6 +14,18 @@
> ># See the License for the specific language governing permissions and
> ># limitations under the License.
> >
> >+if ARGV.include?('-h') || ARGV.include?('--help')
> >+ puts "Usage: #{$0} [OPTION]
> >+Restart Aeolus services.
> >+
> >+ -h, --help display this help and exit
> >+
> >+To show status of aeolus services please use aeolus-check-services.
> >+"
> >+
> >+ exit
> >+end
> >+
>
> This is fine 'for now', but I would really like to see our
> scripts/executable in general cleaned up a bit. Imo, we should be
> parsing cli arguments with ruby's built in optparser, which would make
> the above something like:
>
> OptionParser.new do|opts|
> opts.banner = "Usage: aeolus-restart-services [ options]"
> opts.separator "Restart Aeolus services."
> opts.on( '-h', '--help', 'Get usage information and exit') do
> puts opts
> exit(0)
> end
> end
>
> This could then be slightly refactored to pass in the service name and
> perhaps yield to any additional arguments a specific command has.
> This make our cli tools more extensible and elliminates the
> duplication I see in these 2 patches.
>
> I think the rest of these scripts could use some cleanup as well,
> maybe we can do some refactoring after this bugfix/release phase is
> over.
> Further, maybe we can hatch a strategy/overall design pattern to
> follow for these things, so they are both consistent and resuse as
> much common code as possible.
>
Erm... yes. Can we have an outright ban on pain of ><}}}*> for anyone
pushing option-parsing code that does not use the appropriate
option-parsing builtin for the language they're using?
Thanks,
--Hugh
--
== Hugh Brock, hbrock at redhat.com ==
== Engineering Manager, Cloud BU ==
== Aeolus Project: Manage virtual infrastructure across clouds. ==
== http://aeolusproject.org ==
"I know that you believe you understand what you think I said, but I’m
not sure you realize that what you heard is not what I meant."
--Robert McCloskey
More information about the aeolus-devel
mailing list