Skip to content

Commit ff88112

Browse files
authored
Merge pull request #216 from appwrite/fix-cli-version-issue
fix: allow cli version command without appwrite init
2 parents 1428142 + deecc3d commit ff88112

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

templates/cli/src/Client.php.twig

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,6 @@ class Client
5050
{% endfor %}
5151
];
5252
53-
/**
54-
* SDK constructor.
55-
*/
56-
public function __construct()
57-
{
58-
if (!$this->loadPreferences()) {
59-
Console::error("❌ Oops We were unable to load your preferences. Ensure that you have run '{{ language.params.executableName }} init' before using the CLI");
60-
Console::exit();
61-
}
62-
$this
63-
{% for header in spec.global.headers %}
64-
{% if header.key != 'Mode' and header.key != 'JWT' %}
65-
->set{{header.key | caseUcfirst}}($this->preferences['{{header.name}}'])
66-
{% endif %}
67-
{% endfor %}
68-
;
69-
}
70-
7153
/**
7254
* Getter for preferences
7355
*
@@ -193,6 +175,20 @@ class Client
193175
*/
194176
public function call($method, $path = '', $headers = array(), array $params = array())
195177
{
178+
179+
if (!$this->loadPreferences()) {
180+
Console::error("❌ Oops We were unable to load your preferences. Ensure that you have run '{{ language.params.executableName }} init' before using the CLI");
181+
Console::exit();
182+
}
183+
184+
$this
185+
{% for header in spec.global.headers %}
186+
{% if header.key != 'Mode' and header.key != 'JWT' %}
187+
->set{{header.key | caseUcfirst}}($this->preferences['{{header.name}}'])
188+
{% endif %}
189+
{% endfor %}
190+
;
191+
196192
$headers = array_merge($this->headers, $headers);
197193
$ch = curl_init($this->getPreference(self::PREFERENCE_ENDPOINT) . $path . (($method == self::METHOD_GET && !empty($params)) ? '?' . http_build_query($params) : ''));
198194
$responseHeaders = [];

0 commit comments

Comments
 (0)