8ba5a0 Update `path' functionality:

Authored and Committed by areguera 13 years ago
    Update `path' functionality:
    
        - Update path_doCopy.sh to reflect changes inside texinfo
          documentation structure definition.
    
        - Update command-line arguments interpretation inside
          path_getActions.sh.
    
        - Remove `Define global variables' comment from path.sh. 
    
    
        
Scripts/Bash/Functions/Path/path.sh CHANGED
@@ -26,8 +26,6 @@
26
26
27
27
function path {
28
28
29
- # Define global variables.
30
-
31
29
# Define command-line interface.
32
30
path_getActions
33
31
Scripts/Bash/Functions/Path/path_doCopy.sh CHANGED
@@ -28,73 +28,82 @@ function path_doCopy {
28
28
29
29
local -a SRC
30
30
local -a DST
31
+ local -a DOC
31
32
local COUNT=0
32
-
33
- # Define source locations.
34
- SRC[0]=$SOURCE
35
- SRC[1]=$(cli_getRepoDirParallel ${SRC[0]} "$(cli_getRepoTLDir)/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir '--basename')").texi
36
- SRC[2]=$(cli_getRepoDirParallel ${SRC[0]} "$(cli_getRepoTLDir)/Scripts/Bash/Functions/Render/Config")
37
- SRC[3]=$(cli_getRepoDirParallel ${SRC[0]} "$(cli_getRepoTLDir)/Translations")
38
-
39
- # Define target locations.
33
+
34
+ # Verify target variable. We can't continue if target is empty.
35
+ if [[ $TARGET == '' ]];then
36
+ cli_printMessage "`gettext "There is no target to work with."`" 'AsErrorLine'
37
+ cli_printMessage "$(caller)" 'AsToKnowMoreLine'
38
+ fi
39
+
40
+ # Define source locations. Start with parent directory at position
41
+ # zero and continue with parent directory related parallel
42
+ # directories.
43
+ SRC[0]=$ACTIONVAL
44
+ SRC[1]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${SRC[0]}" "--relative")").texi
45
+ SRC[2]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Scripts/Bash/Functions/Render/Config")
46
+ SRC[3]=$(cli_getRepoDirParallel "${SRC[0]}" "$(cli_getRepoTLDir "${SRC[0]}")/Translations")
47
+
48
+ # Define target locations. Start with parent directory at position
49
+ # zero and continue with parent directory related parallel
50
+ # directories.
40
51
DST[0]=$TARGET
41
- DST[1]=$(cli_getRepoDirParallel ${DST[0]} "$(cli_getRepoTLDir)/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir '--basename')").texi
42
- DST[2]=$(cli_getRepoDirParallel ${DST[0]} "$(cli_getRepoTLDir)/Scripts/Bash/Functions/Render/Config")
43
- DST[3]=$(cli_getRepoDirParallel ${DST[0]} "$(cli_getRepoTLDir)/Translations")
52
+ DST[1]=$(cli_getRepoDirParallel "${DST[0]}" "$(cli_getRepoTLDir "${DST[0]}")/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${DST[0]}" "--relative")").texi
53
+ DST[2]=$(cli_getRepoDirParallel "${DST[0]}" "$(cli_getRepoTLDir "${DST[0]}")/Scripts/Bash/Functions/Render/Config")
54
+ DST[3]=$(cli_getRepoDirParallel "${DST[0]}" "$(cli_getRepoTLDir "${DST[0]}")/Translations")
55
+
56
+ # Define documentation files that need to be counted inside
57
+ # changes commited up to central repository.
58
+ DOC[0]=/home/centos/artwork/trunk/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${DST[0]}" '--relative')/chapter-menu.texi
59
+ DOC[1]=/home/centos/artwork/trunk/Manuals/$(cli_getCurrentLocale)/Texinfo/Repository/$(cli_getRepoTLDir "${DST[0]}" '--relative')/chapter-nodes.texi
44
60
45
61
# Syncronize changes between working copy and central repository.
46
- cli_commitRepoChanges "${SRC[@]} ${DST[@]}"
62
+ cli_commitRepoChanges "${SRC[@]} ${DST[@]} ${DOC[@]}"
47
63
48
- # Output entries affected by action.
49
- cli_printMessage "`ngettext "The following entry will be created:" \
50
- "The following entries will be created:" \
51
- "${#DST[*]}"`"
52
- while [[ $COUNT -lt ${#SRC[*]} ]];do
64
+ # Print preamble with affected entries.
65
+ cli_printMessage "`ngettext "The following entry will be created" \
66
+ "The following entries will be created" "${#DST[*]}"`"
67
+ while [[ $COUNT -lt ${#DST[*]} ]];do
68
+ # Print affected entry.
53
69
cli_printMessage "${DST[$COUNT]}" 'AsResponseLine'
70
+ # Increment counter.
54
71
COUNT=$(($COUNT + 1))
55
72
done
56
73
57
- # Request confirmation to perform action.
58
- cli_printMessage "`gettext "Do you want to continue?"`" 'AsYesOrNoRequestLine'
74
+ # Request confirmation question to continue with action.
75
+ cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine'
59
76
60
77
# Reset counter.
61
78
COUNT=0
62
79
63
- # Perform action.
80
+ while [[ $COUNT -lt ${#DST[*]} ]];do
64
- while [[ $COUNT -lt ${#SRC[*]} ]];do
65
-
66
- cli_printMessage ${DST[$COUNT]} 'AsCreatingLine'
67
81
68
- # Verify repository entry. We cannot duplicate an entry if its
69
- # parent directory doesn't exist as entry inside the working
70
- # copy.
82
+ # Verify relation between source and target locations. We
83
+ # cannot duplicate an entry if its parent directory doesn't
84
+ # exist as entry inside the working copy.
71
85
if [[ -f ${SRC[$COUNT]} ]];then
72
- if [[ -d $(dirname ${SRC[$COUNT]}) ]];then
73
- if [[ ! -d $(dirname ${DST[$COUNT]}) ]];then
74
- mkdir -p $(dirname ${DST[$COUNT]})
86
+ if [[ ! -d $(dirname ${DST[$COUNT]}) ]];then
87
+ mkdir -p $(dirname ${DST[$COUNT]})
88
+ svn add $(dirname ${DST[$COUNT]}) --quiet
75
- svn add $(dirname ${DST[$COUNT]}) --quiet
76
- fi
77
- fi
78
- elif [[ -d ${SRC[$COUNT]} ]];then
79
- if [[ -d ${DST[$COUNT]} ]];then
80
- cli_printMessage "`gettext "cannot create "` \`${DST[$COUNT]}': `gettext "Directory already exists."`" 'AsErrorLine'
81
- cli_printMessage "$(caller)" 'AsToKnowMoreLine'
82
89
fi
83
90
fi
84
91
85
- # Copy using subversion command.
92
+ # Print action message.
93
+ cli_printMessage "${DST[$COUNT]}" 'AsCreatingLine'
94
+
95
+ # Perform action.
86
96
svn copy ${SRC[$COUNT]} ${DST[$COUNT]} --quiet
87
97
88
98
# Increase counter.
89
99
COUNT=$(($COUNT + 1))
90
100
91
- done
101
+ done
92
102
93
- # Update documentation chapter, menu and nodes inside Texinfo
94
- # documentation structure.
103
+ # Update texinfo documentation structure.
104
+ . /home/centos/bin/centos-art manual --update-structure="${DST[0]}"
95
- . ~/bin/centos-art manual --update-structure=${DST[0]}
96
105
97
106
# Syncronize changes between working copy and central repository.
98
- cli_commitRepoChanges "${DST[@]}"
107
+ cli_commitRepoChanges "${SRC[@]} ${DST[@]} ${DOC[@]}"
99
108
100
109
}
Scripts/Bash/Functions/Path/path_getActions.sh CHANGED
@@ -1,7 +1,7 @@
1
1
#!/bin/bash
2
2
#
3
- # path_getActions.sh -- This function defines the command-line
4
- # interface used to manipulate repository files.
3
+ # path_getActions.sh -- This function interpretes arguments passed to
4
+ # `path' functionality and calls actions accordingly.
5
5
#
6
6
# Copyright (C) 2009, 2010 Alain Reguera Delgado
7
7
#
@@ -26,14 +26,11 @@
26
26
27
27
function path_getActions {
28
28
29
- # Define source location we are going to work with.
30
- local SOURCE="$ACTIONVAL"
31
-
32
29
# Define short options we want to support.
33
- local ARGSS="r:m:t:"
30
+ local ARGSS=""
34
31
35
32
# Define long options we want to support.
36
- local ARGSL="revision:,message:,to:"
33
+ local ARGSL="copy:,move:,delete:,to:"
37
34
38
35
# Parse arguments using getopt(1) command parser.
39
36
cli_doParseArguments
@@ -42,59 +39,121 @@ function path_getActions {
42
39
# parser.
43
40
eval set -- "$ARGUMENTS"
44
41
45
- # Define target locations using positonal parameters as
42
+ # Define action to take for each option passed.
46
- # reference.
47
43
while true; do
48
44
case "$1" in
49
- -t|--to )
50
- TARGET="$2"
51
- cli_checkRepoDirTarget
52
- shift 2
53
- ;;
54
- * )
55
- break
56
- esac
57
- done
58
45
59
- # Redefine positional parameters stored inside ARGUMENTS variable.
46
+ --copy )
60
- cli_doParseArgumentsReDef "$@"
61
47
62
- # Parse positional parameters stored inside ARGUMENTS variable.
63
- cli_doParseArguments
48
+ # Define action value passed through the command-line.
49
+ ACTIONVAL="$2"
64
50
65
- # Evaluate action name and define which actions does centos-art.sh
66
- # script supports.
67
- while true; do
51
+ # Check action value passed through the command-line
52
+ # using source directory definition as reference.
53
+ cli_checkRepoDirSource
68
- case "$ACTIONNAM" in
69
54
70
- '--copy' )
71
- # Duplicate something in working copy or repository,
55
+ # Define action name using action value as reference.
56
+ ACTIONNAM="${FUNCNAM}_doCopy"
72
- # remembering history.
73
- path_doCopy
74
- ;;
75
57
76
- '--move' )
77
- # Move and/or rename something in working copy or
78
- # repository.
58
+ # Look for related sub-options.
59
+ while true; do
60
+ case "$3" in
79
- # --- path_doMove
80
- ;;
81
61
82
- '--delete' )
83
- # Remove files and directories from version control.
84
- # --- path_doDelete
62
+ --to )
63
+
64
+ # Redefine target directory.
65
+ TARGET="$4"
66
+
67
+ # Verify target directory.
68
+ cli_checkRepoDirTarget
69
+
70
+ # Rotate positional parameters.
71
+ shift 4
72
+ ;;
73
+
74
+ * )
75
+ # Break sub-options loop.
76
+ break
77
+ ;;
78
+ esac
79
+ done
80
+
81
+ # Break options loop.
82
+ break
85
83
;;
86
-
87
- '--sync' )
88
- # Syncronize parallel dirctories with parent directory.
89
- # --- path_doSync
84
+
85
+ --move )
86
+
87
+ # Define action value passed through the command-line.
88
+ ACTIONVAL="$2"
89
+
90
+ # Check action value passed through the command-line
91
+ # using source directory definition as reference.
92
+ cli_checkRepoDirSource
93
+
94
+ # Define action name using action value as reference.
95
+ ACTIONNAM="${FUNCNAM}_doMove"
96
+
97
+ # Look for related sub-options.
98
+ while true; do
99
+ case "$3" in
100
+
101
+ --to )
102
+
103
+ # Redefine target directory.
104
+ TARGET="$4"
105
+
106
+ # Verify target directory.
107
+ cli_checkRepoDirTarget
108
+
109
+ # Rotate positional parameters.
110
+ shift 4
111
+ ;;
112
+
113
+ * )
114
+ # Break sub-options loop.
115
+ break
116
+ ;;
117
+ esac
118
+ done
119
+
120
+ # Break options loop.
121
+ break
90
122
;;
91
123
92
- * )
93
- cli_printMessage "`gettext "The action provided is not valid."`" 'AsErrorLine'
94
- cli_printMessage "$(caller)" 'AsToKnowMoreLine'
124
+ --delete )
125
+
126
+ # Define action value passed through the command-line.
127
+ ACTIONVAL="$2"
128
+
129
+ # Check action value passed through the command-line
130
+ # using source directory definition as reference.
131
+ cli_checkRepoDirSource
132
+
133
+ # Define action name using action value as reference.
134
+ ACTIONNAM="${FUNCNAM}_doDelete"
135
+
136
+ # Break options loop.
137
+ break
95
138
;;
96
139
140
+ * )
141
+ # Break options loop.
142
+ break
97
143
esac
98
144
done
99
-
145
+
146
+ # Verify action value variable.
147
+ if [[ $ACTIONVAL == '' ]];then
148
+ cli_printMessage "$(caller)" 'AsToKnowMoreLine'
149
+ fi
150
+
151
+ # Execute action name.
152
+ if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
153
+ eval $ACTIONNAM
154
+ else
155
+ cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine'
156
+ cli_printMessage "$(caller)" 'AsToKnowMoreLine'
157
+ fi
158
+
100
159
}