mdsb100 / cli-gitlab

GitLab CLI library
101 stars 11 forks source link

possibility to use namspace_name instead of id ? #4

Closed strowi closed 8 years ago

strowi commented 9 years ago

Hi,

nice cli-tool.;) But using namespace_ids to create projects in diferent groups is quite cumbersome. I would be very nice if there was a possibility to use the name itself. E.g:

~> gitlab createProject --name testing --namespace testgroup 
mdsb100 commented 9 years ago

Hi, @strowi I just wrap 'node-gitlab' for CLI. 'node-gitlab' is GitLab API Nodejs library. It wraps the HTTP api library. So in 'node-gitlab':

Projects.prototype.create = function(params, fn) {
      if (params == null) {
        params = {};
      }
      if (fn == null) {
        fn = null;
      }
      this.debug("Projects::create()");
      return this.post("projects", params, function(data) {
        if (fn) {
          return fn(data);
        }
      });
    };

GitLab document:

Create project

Creates a new project owned by the authenticated user.

POST /projects
Parameters:

name (required) - new project name
path (optional) - custom repository name for new project. By default generated based on name
namespace_id (optional) - namespace for the new project (defaults to user)
description (optional) - short project description
issues_enabled (optional)
merge_requests_enabled (optional)
wiki_enabled (optional)
snippets_enabled (optional)
public (optional) - if true same as setting visibility_level = 20
visibility_level (optional)
import_url (optional)

I am afraid there is not a possibility to use name itself.

You should get all namespace and filter name to get namespace id. Then you can create project by this id.

Maybe I can create interactive CLI.

gitlab createProject --name testing
Which namespace do you chose? // Fetch all namespaces and print all.
1: testGroup
2:android
3:ios
3 // User input 3. I get the id of 'ios' and post it.

There is no need for this. User can use website to finish creating project easily.

But in 'node-gitlab 2', the callback will return a promise. If user use --namespace, 'cli-gitlab' will fetch all namespaces and filter namespace to get namespace_id.

strowi commented 9 years ago

Hi mdsb100,

thank you for the fast response.

Ok, didn't look too deep into the api-doc. As Sysadmin i do manage the repos/jenkins etc.. and would like to do it all with a single command instead of logging in to each service.

regards, strowi