Skip to content

Commit 4c4b15b

Browse files
introducing wrong arguments error
1 parent e52c042 commit 4c4b15b

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[Makefile]
18+
indent_style = tab

Forkfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM https://github.com/javanile/php-package 1.x

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!make
2+
3+
readme-standard:
4+
@curl -s https://www.javanile.org/readme-standard/checker.sh?t=$$(date +%s) | bash

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
The best way to import SQL file on your database.
99

10+
## UsageA
11+
1012
## Get started
1113

1214
```bash
@@ -17,6 +19,11 @@ $ composer require javanile/mysql-import
1719
$ ./vendor/bin/mysql-import database.sql
1820
```
1921

22+
## Usage
23+
This is how to use this
24+
This is how to use this
25+
26+
2027
## Testing
2128

2229
```bash

src/MysqlImport.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ class MysqlImport
7474
*/
7575
protected $doWhile;
7676

77+
/**
78+
* @var boolean
79+
*/
80+
protected $force;
81+
7782
/**
7883
* @var boolean
7984
*/
@@ -95,6 +100,7 @@ public function __construct($env, $argv)
95100
$this->exitCode = 0;
96101
$this->loader = '/\______';
97102
$this->doWhile = in_array('--do-while', $argv);
103+
$this->force = in_array('--force', $argv);
98104

99105
$defaultDatabase = isset($env['WORDPRESS_DB_PASSWORD']) ? 'wordpress' : 'database';
100106

@@ -118,6 +124,7 @@ public function __construct($env, $argv)
118124

119125
// Get value from command-line argument
120126
if ($opt[2] && $arg = preg_grep('/^'.$opt[2].'[\S]*/', $argv)) {
127+
var_dump($arg);
121128
$value = substr(end($arg), strlen($opt[2]));
122129
}
123130

@@ -152,7 +159,7 @@ public function __construct($env, $argv)
152159
}
153160

154161
/**
155-
* Command entrypoint.
162+
* Command entry-point.
156163
*/
157164
public function run()
158165
{
@@ -207,7 +214,7 @@ protected function tryUserAndPassword()
207214
}
208215

209216
//
210-
if (!$this->blank()) {
217+
if (!$this->blank() && !$this->force) {
211218
return $this->messageDatabaseNotBlank();
212219
}
213220

@@ -238,7 +245,7 @@ protected function tryRootPassword()
238245

239246
// try to import
240247
if ($this->exists()) {
241-
if ($this->blank()) {
248+
if ($this->blank() || $this->force) {
242249
return $this->import();
243250
}
244251

0 commit comments

Comments
 (0)