Skip to content

Commit 87070b3

Browse files
DOCSP-15141 Add support for MongoDB Shell to MongoDB CLI (#526)
* DOCSP-15141 Add support for MongoDB Shell to MongoDB CLI * DOCSP-15141 updates for review feedback
1 parent 3119a64 commit 87070b3

8 files changed

+106
-35
lines changed

source/configure/configuration-file.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ profile by the number of profiles you have configured:
6767
Example
6868
-------
6969

70-
The following example configuration file contains two profiles,
71-
``default`` and ``myOpsManager``.
70+
The following example configuration file contains the path to the
71+
|mongo| shell and two profiles, ``default`` and ``myOpsManager``.
7272

7373
The ``default`` profile connects to an |service| deployment and contains
7474
the following settings:
@@ -95,6 +95,8 @@ contains the following settings:
9595

9696
# ~/.config/mongocli.toml
9797

98+
mongosh_path = "/usr/local/bin/mongosh"
99+
98100
[default]
99101
organization_id = "qwer5678uiop23jb45lk78mn"
100102
public_api_key = "ABCDEFG"

source/includes/config-set-properties.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
* - ``private_api_key``
1818
- Private key for programmatic access.
1919

20+
* - ``mongosh_path``
21+
- Path to the |mongo| shell on your system. The default value is
22+
``/usr/local/bin/mongosh``.
23+
2024
* - ``ops_manager_url``
2125
- **Ops Manager only.** |mms| base URL. The |url| must end with a
2226
forward slash (i.e. ``/``).

source/includes/steps-configure-mcli-atlas.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ source:
2424
ref: enter-projectid
2525
---
2626
stepnum: 5
27+
source:
28+
file: steps-configure-mcli.yaml
29+
ref: enter-mongo-shell-path
30+
---
31+
stepnum: 6
2732
source:
2833
file: steps-configure-mcli.yaml
2934
ref: verify-profile

source/includes/steps-configure-mcli-cm.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ source:
2424
ref: enter-projectid
2525
---
2626
stepnum: 5
27+
source:
28+
file: steps-configure-mcli.yaml
29+
ref: enter-mongo-shell-path
30+
---
31+
stepnum: 6
2732
source:
2833
file: steps-configure-mcli.yaml
2934
ref: verify-profile

source/includes/steps-configure-mcli-om.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ source:
2828
file: steps-configure-mcli.yaml
2929
ref: enter-projectid
3030
---
31+
stepnum: 5
32+
source:
33+
file: steps-configure-mcli.yaml
34+
ref: enter-mongo-shell-path
35+
---
3136
stepnum: 6
3237
source:
3338
file: steps-configure-mcli.yaml

source/includes/steps-configure-mcli.yaml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ content: |
7979
.. code-block:: sh
8080
:copyable: false
8181
82-
? Public API Key: abcdef
82+
? Public API Key: [? for help] abcdef
8383
? Private API Key: [? for help]
8484
************************************
8585
@@ -102,7 +102,7 @@ content: |
102102
.. code-block:: sh
103103
:copyable: false
104104
105-
? Choose a default organization: [Use arrows to move, type to filter]
105+
? Default Org ID: [Use arrows to move, type to filter]
106106
> Org1 (5e39bf1212121e685774c81c)
107107
108108
#. Press :kbd:`Enter`.
@@ -130,7 +130,7 @@ content: |
130130
.. code-block:: sh
131131
:copyable: false
132132
133-
? Choose a default project: [Use arrows to move, type to filter]
133+
? Default Project ID: [Use arrows to move, type to filter]
134134
Project1 (5e5ebffd0c04a97009061234)
135135
Project2 (5cfacee6014b761b07f15678)
136136
> Project3 (5e39bf4979358e6857741212)
@@ -140,6 +140,26 @@ content: |
140140
141141
If you didn't enter |api| keys, the command prompts you to enter your
142142
``Default Project ID``.
143+
---
144+
title: "Specify the path to |mongo| shell on your system."
145+
stepnum: 0
146+
level: 4
147+
ref: enter-mongo-shell-path
148+
content: |
149+
150+
{+mcli+} uses the |mongo| shell path that you specify to allow you to
151+
access your deployments. The default value is
152+
``/usr/local/bin/mongosh``. Press :kbd:`Enter` to accept the default
153+
or:
154+
155+
a. Specify the path to |mongo| shell on your system.
156+
157+
.. code-block:: sh
158+
:copyable: false
159+
160+
? Default MongoDB Shell Path: [? for help] (/usr/local/bin/mongosh)
161+
162+
#. Press :kbd:`Enter`.
143163
144164
---
145165
title: "Verify your profile."
@@ -172,18 +192,21 @@ content: |
172192
173193
mongocli config describe default
174194
175-
The command returns the following settings. For security
176-
purposes, the command redacts |api| keys in the output.
195+
The preceding command returns the following settings. For
196+
security purposes, the command redacts |api| keys in the
197+
output.
177198
178199
.. code-block:: sh
179200
:copyable: false
180201
202+
SETTING VALUE
203+
mongosh_path /usr/local/bin/mongosh
181204
{{opsMgrUrl}}
182-
org_id = 5f1f39ffc902201990f12345
183-
private_api_key = redacted
184-
project_id = 7ehf04abc10defb66c7d1234c
185-
public_api_key = redacted
186-
service = {{serviceName}}
205+
org_id 5f1f39ffc902201990f12345
206+
private_api_key redacted
207+
project_id 7ehf04abc10defb66c7d1234c
208+
public_api_key redacted
209+
service {{serviceName}}
187210
188211
.. tab:: Named Profile
189212
:tabid: named-profile
@@ -204,12 +227,13 @@ content: |
204227
.. code-block:: sh
205228
:copyable: false
206229
230+
SETTING VALUE
207231
{{opsMgrUrl}}
208-
org_id = 5f1f39ffc902201990f12345
209-
private_api_key = redacted
210-
project_id = 7ehf04abc10defb66c7d1234c
211-
public_api_key = redacted
212-
service = {{serviceName}}
232+
org_id 5f1f39ffc902201990f12345
233+
private_api_key redacted
234+
project_id 7ehf04abc10defb66c7d1234c
235+
public_api_key redacted
236+
service {{serviceName}}
213237
214238
---
215239
title: "Customize the {+mcli+} output using a Go template."

source/reference/config.txt

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ When you run the command, it prompts you for the following information:
5959
- ID of your project.
6060
- Optional.
6161

62+
* - Default MongoDB Shell Path
63+
- Path to |mongo| shell on your system. The default value is
64+
``/usr/local/bin/mongosh``.
65+
- Optional.
66+
6267
{+mcli+} saves these settings as a profile in the :ref:`mcli-config-file`.
6368

6469
.. _mcli-config-command-syntax:
@@ -143,10 +148,11 @@ The following examples use the ``mongocli config`` command to:
143148

144149
~ mongocli config
145150

146-
? Public API Key: abcdefgh
151+
? Public API Key: [? for help] abcdefgh
147152
? Private API Key: [? for help] ************************************
148-
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
149-
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)
153+
? Default Org ID: [? for help] 5c815cc7d5ec13092a02a1b2
154+
? Default Project ID: [? for help] 5e5ebffd0c04a9700906c3d4
155+
? Default MongoDB Shell Path: [? for help] /usr/local/bin/mongosh
150156

151157
**Example 2**
152158

@@ -158,10 +164,11 @@ The following examples use the ``mongocli config`` command to:
158164

159165
~ mongocli config --profile Profile1
160166

161-
? Public API Key: abcdefgh
167+
? Public API Key: [? for help] abcdefgh
162168
? Private API Key: [? for help] ************************************
163-
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
164-
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)
169+
? Default Org ID: [? for help] Org1 (5c815cc7d5ec13092a02a1b2)
170+
? Default Project ID: [? for help] Project1 (5e5ebffd0c04a9700906c3d4)
171+
? Default MongoDB Shell Path: [? for help] (/usr/local/bin/mongosh)
165172

166173
.. tab:: Cloud Manager
167174
:tabid: cloud-manager
@@ -176,10 +183,10 @@ The following examples use the ``mongocli config`` command to:
176183

177184
~ mongocli config --service cloud-manager
178185

179-
? Public API Key: abcdefgh
186+
? Public API Key: [? for help] abcdefgh
180187
? Private API Key: [? for help] ************************************
181-
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
182-
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)
188+
? Default Org ID: [? for help] Org1 (5c815cc7d5ec13092a02a1b2)
189+
? Default Project ID: [? for help] Project1 (5e5ebffd0c04a9700906c3d4)
183190

184191
**Example 2**
185192

@@ -191,10 +198,10 @@ The following examples use the ``mongocli config`` command to:
191198

192199
~ mongocli config --service cloud-manager --profile Profile1
193200

194-
? Public API Key: abcdefgh
201+
? Public API Key: [? for help] abcdefgh
195202
? Private API Key: [? for help] ************************************
196-
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
197-
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)
203+
? Default Org ID: [? for help] Org1 (5c815cc7d5ec13092a02a1b2)
204+
? Default Project ID: [? for help] Project1 (5e5ebffd0c04a9700906c3d4)
198205

199206
.. tab:: Ops Manager
200207
:tabid: ops-manager
@@ -210,10 +217,10 @@ The following examples use the ``mongocli config`` command to:
210217
~ mongocli config --service ops-manager
211218

212219
? URL to Access Ops Manager: https://mms.example.com:8080/
213-
? Public API Key: abcdefgh
220+
? Public API Key: [? for help] abcdefgh
214221
? Private API Key: [? for help] ************************************
215-
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
216-
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)
222+
? Default Org ID: [? for help] Org1 (5c815cc7d5ec13092a02a1b2)
223+
? Default Project ID: [? for help] Project1 (5e5ebffd0c04a9700906c3d4)
217224

218225
**Example 2**
219226

@@ -226,7 +233,7 @@ The following examples use the ``mongocli config`` command to:
226233
mongocli config --service ops-manager --profile Profile1
227234

228235
? URL to Access Ops Manager: https://mms.example.com:8080/
229-
? Public API Key: abcdefgh
236+
? Public API Key: [? for help] abcdefgh
230237
? Private API Key: [? for help] ************************************
231-
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
232-
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)
238+
? Default Org ID:[? for help] Org1 (5c815cc7d5ec13092a02a1b2)
239+
? Default Project ID:[? for help] Project1 (5e5ebffd0c04a9700906c3d4)

source/reference/mcli-config-set.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Options
7070
- Unique identifier of the project for ``project_id``
7171
- Public |api| key for ``public_api_key``
7272
- Private |api| key for ``private_api_key``
73+
- Path to the |mongo| shell for ``mongosh_path``
7374
- |mms| base URL for ``ops_manager_url``
7475
- Full path to the CA certificate for
7576
``ops_manager_ca_certificate``
@@ -97,6 +98,7 @@ where ``<property-name>`` can be:
9798
- ``project_id``
9899
- ``public_api_key``
99100
- ``private_api_key``
101+
- ``mongosh_path``
100102
- ``ops_manager_url``
101103
- ``ops_manager_ca_certificate``
102104
- ``ops_manager_skip_verify``
@@ -196,6 +198,23 @@ The previous command prints the following to the terminal:
196198

197199
Updated prop 'private_api_key'
198200

201+
Set Path for |mongo| Shell
202+
~~~~~~~~~~~~~~~~~~~~~~~~~~
203+
204+
The following example uses the ``mongocli config set`` command to
205+
set the path for the |mongo| shell on the system:
206+
207+
.. code-block:: sh
208+
209+
mongocli config set mongosh_path /usr/local/bin/mongosh
210+
211+
The previous command prints the following output to the terminal:
212+
213+
.. code-block:: sh
214+
:copyable: false
215+
216+
Updated property 'mongosh_path'
217+
199218
Set Custom CA Certificate File
200219
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201220

0 commit comments

Comments
 (0)