From b5499b8a2f0175913002d5a2b789f15fe4705269 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 13 Dec 2013 10:28:05 +0100 Subject: [PATCH] Added autocompletion in irpman --- bin/irpman | 36 +++++++++++++++++++++--------------- src/irpman.py | 39 +++++++++++++++++++++++++++++++++++++++ src/version.py | 2 +- 3 files changed, 61 insertions(+), 16 deletions(-) create mode 100755 src/irpman.py diff --git a/bin/irpman b/bin/irpman index fac6e30..f102f6a 100755 --- a/bin/irpman +++ b/bin/irpman @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/bin/bash # IRPF90 is a Fortran90 preprocessor written in Python for programming using # the Implicit Reference to Parameters (IRP) method. # Copyright (C) 2009 Anthony SCEMAMA @@ -24,19 +24,25 @@ # 31062 Toulouse Cedex 4 # scemama@irsamc.ups-tlse.fr +# Define auto-completion for bash -import os -import sys - -wd = os.path.abspath(os.path.dirname(__file__)) -sys.path.insert(0,(wd+"/../src/")) -sys.path.insert(0,(wd+"/../share/irpf90/src/")) - -if len(sys.argv) != 2: - print "Usage:" - print sys.argv[0]+" " - sys.exit(1) - -from irpf90_t import mandir -os.system("man ./"+mandir+sys.argv[1].lower()+".l") +case "$0" in + *bash*) + _irpman_complete() + { + local cur + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + COMPREPLY=( $(compgen -W "`cat irpf90_entities | cut -d':' -f 4 | cut -d ' ' -f 2`" -- "$cur" ) ) + } && complete -F _irpman_complete irpman + ;; + *) + if [[ -z $1 ]] ; then + echo "To activate auto-completion in bash:" + echo "source $(which irpman)" + else + python $(dirname $0)/../src/irpman.py $1 + fi + ;; +esac diff --git a/src/irpman.py b/src/irpman.py new file mode 100755 index 0000000..c0253a8 --- /dev/null +++ b/src/irpman.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +# IRPF90 is a Fortran90 preprocessor written in Python for programming using +# the Implicit Reference to Parameters (IRP) method. +# Copyright (C) 2009 Anthony SCEMAMA +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Anthony Scemama +# LCPQ - IRSAMC - CNRS +# Universite Paul Sabatier +# 118, route de Narbonne +# 31062 Toulouse Cedex 4 +# scemama@irsamc.ups-tlse.fr + + +import os +import sys + +wd = os.path.abspath(os.path.dirname(__file__)) +from irpf90_t import mandir +filename = sys.argv[1].lower()+".l" +if filename not in os.listdir(mandir): + print "%s does not exist"%(sys.argv[1]) + sys.exit(-1) + +os.system("man ./"+mandir+sys.argv[1].lower()+".l") + diff --git a/src/version.py b/src/version.py index 253dc6a..35ec9a3 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.3.00" +version = "1.3.1"