Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
b005689e
Commit
b005689e
authored
Oct 10, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More changes to Cli system.
parent
4e877c52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
22 deletions
+67
-22
Cli.php
lib/Doctrine/Cli.php
+39
-9
Task.php
lib/Doctrine/Cli/Task.php
+28
-13
No files found.
lib/Doctrine/Cli.php
View file @
b005689e
...
...
@@ -32,8 +32,13 @@
*/
class
Doctrine_Cli
{
protected
$tasks
=
array
();
protected
$scriptName
=
null
;
public
function
run
(
$args
)
{
$this
->
scriptName
=
$args
[
0
];
if
(
!
isset
(
$args
[
1
]))
{
echo
$this
->
printTasks
();
return
;
...
...
@@ -64,25 +69,48 @@ class Doctrine_Cli
echo
"
\n
Available Doctrine Command Line Interface Tasks
\n
"
;
echo
str_repeat
(
'-'
,
40
)
.
"
\n\n
"
;
foreach
(
$tasks
as
$taskName
)
{
$className
=
'Doctrine_Cli_Task_'
.
$taskName
;
$taskInstance
=
new
$className
();
$taskInstance
->
taskName
=
str_replace
(
'_'
,
'-'
,
Doctrine
::
tableize
(
$taskName
));
echo
"Name: "
.
$taskInstance
->
getName
()
.
"
\n
"
;
echo
"Description: "
.
$taskInstance
->
getDescription
()
.
"
\n
"
;
echo
$taskInstance
->
getDescription
()
.
"
\n
"
;
$syntax
=
"Syntax: "
;
if
(
$requiredArguments
=
$taskInstance
->
getRequiredArguments
())
{
echo
"Required Arguments: "
.
implode
(
', '
,
$requiredArguments
)
.
"
\n
"
;
$syntax
.=
$this
->
scriptName
.
' '
.
$taskInstance
->
getTaskName
();
if
(
$required
=
$taskInstance
->
getRequiredArguments
())
{
$syntax
.=
' <'
.
implode
(
'> <'
,
$required
)
.
'>'
;
}
if
(
$optional
=
$taskInstance
->
getOptionalArguments
())
{
$syntax
.=
' <'
.
implode
(
'> <'
,
$optional
)
.
'>'
;
}
if
(
$optionalArguments
=
$taskInstance
->
getOptionalArguments
())
{
echo
"Optional Arguments: "
.
implode
(
', '
,
$taskInstance
->
getOptionalArguments
())
.
"
\n
"
;
echo
$syntax
.
"
\n
"
;
$args
=
null
;
if
(
$requiredArguments
=
$taskInstance
->
getRequiredArgumentsDescriptions
())
{
foreach
(
$requiredArguments
as
$name
=>
$description
)
{
$args
.=
'*'
.
$name
.
' - '
.
$description
.
"
\n
"
;
}
}
if
(
$optionalArguments
=
$taskInstance
->
getOptionalArgumentsDescriptions
())
{
foreach
(
$requiredArguments
as
$name
=>
$description
)
{
$args
.=
$name
.
' - '
.
$description
.
"
\n
"
;
}
}
echo
"Syntax: "
.
$taskInstance
->
getSyntax
()
.
"
\n
"
;
echo
str_repeat
(
'-'
,
40
)
.
"
\n\n
"
;
if
(
$args
)
{
echo
"
\n
Arguments:
\n
"
;
echo
$args
;
}
echo
"
\n
"
.
str_repeat
(
"-"
,
40
)
.
"
\n
"
;
}
}
...
...
@@ -115,6 +143,8 @@ class Doctrine_Cli
}
}
return
$tasks
;
$this
->
tasks
=
array_merge
(
$this
->
tasks
,
$tasks
);
return
$this
->
tasks
;
}
}
\ No newline at end of file
lib/Doctrine/Cli/Task.php
View file @
b005689e
...
...
@@ -32,13 +32,13 @@
*/
abstract
class
Doctrine_Cli_Task
{
public
$name
=
null
,
$taskName
=
null
,
public
$taskName
=
null
,
$description
=
null
,
$arguments
=
array
(),
$requiredArguments
=
array
(),
$optionalArguments
=
array
();
abstract
function
execute
(
$args
);
abstract
function
execute
();
public
function
validate
(
$args
)
{
...
...
@@ -81,12 +81,19 @@ abstract class Doctrine_Cli_Task
$count
++
;
}
$this
->
arguments
=
$prepared
;
return
$prepared
;
}
public
function
getName
()
public
function
getArgument
(
$name
)
{
return
$this
->
arguments
[
$name
];
}
public
function
getArguments
()
{
return
$this
->
name
;
return
$this
->
arguments
;
}
public
function
getTaskName
()
...
...
@@ -101,28 +108,36 @@ abstract class Doctrine_Cli_Task
public
function
getRequiredArguments
()
{
return
$this
->
requiredArguments
;
return
array_keys
(
$this
->
requiredArguments
)
;
}
public
function
getOptionalArguments
()
{
return
array_keys
(
$this
->
optionalArguments
);
}
public
function
getRequiredArgumentsDescriptions
()
{
return
$this
->
requiredArguments
;
}
public
function
getOptionalArgumentsDescriptions
()
{
return
$this
->
optionalArguments
;
}
public
function
getSyntax
()
{
$taskName
=
$this
->
getTaskName
();
$requiredArguments
=
null
;
$optionalArguments
=
null
;
{
$syntax
=
'./cli '
.
$this
->
getTaskName
();
if
(
$required
=
$this
->
getRequiredArguments
())
{
$
requiredArguments
=
'
<'
.
implode
(
'> <'
,
$required
)
.
'>'
;
$
syntax
.=
'
<'
.
implode
(
'> <'
,
$required
)
.
'>'
;
}
if
(
$optional
=
$this
->
getOptionalArguments
())
{
$optionalArguments
=
'
<'
.
implode
(
'> <'
,
$optional
)
.
'>'
;
$syntax
.=
'
<'
.
implode
(
'> <'
,
$optional
)
.
'>'
;
}
return
'./cli '
.
$taskName
.
' '
.
$requiredArguments
.
' '
.
$optionalArguments
;
return
$syntax
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment