Repository: spyder-ide/spyder

Issue:
Add a command line option to load projects
Is there an option to load a specific project with command line options? Or, alternatively, specify a  different set of configuration files? The reason is that we are working with multiple users on the same account, and we do not want to have our projects and settings mixed.

We already have different spyder versions installed using environments (with conda, windows), but these different spyder versions all use the same configuration files.

## Versions and main components

* Spyder Version: 3.0.2
* Python Version: 3.5
* Operating system: windows




Discussion:
We could easily add a command line option to load a different project, but I'm a bit reluctant to add another one to load different config settings.

Why is not possible for you to let your users use different accounts?
The reason is that there are several instruments (hardware) connected to the machine and we do not want to disconnect these instruments. Logging out and into a different account would disconnect the hardware. 
A command line option to load a specific project would be great. If needed I can look into the code myself, but I am not very familiar with the spyder codebase.
@andfoy, please work on this one.
In Spyder 2.3.9, I tried this code to load a session from script / commande Line, it seems not working :

```
from spyderlib import start_app
main1= start_app.main()
main1.load_session('/project27/test_.session.tar')

```

MainWindow has a method load_session.

Also there is this method :
from spyderlib.utils.iofuncs import load_session

Am not how to get access to the mainWindow object by command line....

@ccordoba12 Do we add both functions? i.e., Load a project file and configuration files?
Nop, just to load a project for now.

Resolving patch:
diff --git a/spyder/app/cli_options.py b/spyder/app/cli_options.py
--- a/spyder/app/cli_options.py
+++ b/spyder/app/cli_options.py
@@ -37,5 +37,8 @@ def get_options():
                            "not related with Python profiling)")
     parser.add_option('--window-title', type=str, default=None,
                       help="String to show in the main window title")
+    parser.add_option('-p', '--project', default=None, type=str,
+                      dest="open_project",
+                      help="Path that contains an Spyder project")
     options, args = parser.parse_args()
     return options, args
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -274,6 +274,7 @@ def __init__(self, options=None):
         self.profile = options.profile
         self.multithreaded = options.multithreaded
         self.new_instance = options.new_instance
+        self.open_project = options.open_project
 
         self.debug_print("Start of MainWindow constructor")
 
@@ -1216,13 +1217,16 @@ def post_visible_setup(self):
         if not self.extconsole.isvisible and not ipy_visible:
             self.historylog.add_history(get_conf_path('history.py'))
 
-        # Load last project if a project was active when Spyder
-        # was closed
-        self.projects.reopen_last_project()
+        if self.open_project:
+            self.projects.open_project(self.open_project)
+        else:
+            # Load last project if a project was active when Spyder
+            # was closed
+            self.projects.reopen_last_project()
 
-        # If no project is active, load last session
-        if self.projects.get_active_project() is None:
-            self.editor.setup_open_files()
+            # If no project is active, load last session
+            if self.projects.get_active_project() is None:
+                self.editor.setup_open_files()
 
         # Check for spyder updates
         if DEV is None and CONF.get('main', 'check_updates_on_startup'):


Test patch: