Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Structure .driverc #778

Closed
jean-christophe-manciot opened this issue Oct 28, 2016 · 7 comments
Closed

[Feature Request] Structure .driverc #778

jean-christophe-manciot opened this issue Oct 28, 2016 · 7 comments

Comments

@jean-christophe-manciot
[global]
key1=value1
key2=value21

[command_1] # such as pull
key3=value31,value32
key4
key5=value51

[command_2] # such as share
key3=value33
key2=value22
key6=value61,value62,value63
...

where the global keys apply until the same keys (options) are overridden by more specific values in [command_n] sections.

Then it's much easier to perform some repetitive commands.

@odeke-em
Copy link
Owner

Hello there @jean-christophe-manciot, thank you for the feature request and for the patience.
I've been very busy but this evening I found time to work on this issue and I'll be pushing up a
PR very soon.

I think this is a very useful feature and I'll be using it quite a lot myself. Thank you!

@odeke-em odeke-em added this to the v0.3.9 milestone Dec 18, 2016
odeke-em added a commit that referenced this issue Dec 18, 2016
Fixes #778.

Now allows you to restructure your .driverc separating
commands into sections and having different clauses.

Please note:
* You can put multiple commands in the same
section by using separator "/". See the rules at
https://github.com/odeke-em/namespace/blob/0ab79ba44f1328b1ec75ea985ad5c338ba3d56a6/ns.go#L3-L14

* Overwriting of command rules is
command_section > global
and
commandX_higher_line > commandX_lower_line
where lines are natural numbers that are ascending

* Exhibits:
This is a sample of a .driverc that I've just defined that has flexible
behavior in different sections.

```
id=true # Will be applied globally unless overwritten in a command

[global]
depth=10 # The depth to use if not defined

[pull/list]
depth=2 # The depth to be used for pull or list

[push]
verbose=true # verbose is only true for push

[list]
long=true # Allow long output for list
```

And see the tests in src/rc_test.go that lock in the promised behavior.
odeke-em added a commit that referenced this issue Dec 18, 2016
Fixes #778.

Now allows you to restructure your .driverc separating
commands into sections and having different clauses.

Please note:
* You can put multiple commands in the same
section by using separator "/". See the rules at
https://github.com/odeke-em/namespace/blob/0ab79ba44f1328b1ec75ea985ad5c338ba3d56a6/ns.go#L3-L14

* Overwriting of command rules is
command_section > global
and
commandX_higher_line > commandX_lower_line
where lines are natural numbers that are ascending

* Exhibits:
This is a sample of a .driverc that I've just defined that has flexible
behavior in different sections.

```
id=true # Will be applied globally unless overwritten in a command

[global]
depth=10 # The depth to use if not defined

[pull/list]
depth=2 # The depth to be used for pull or list

[push]
verbose=true # verbose is only true for push

[list]
long=true # Allow long output for list
```

And see the tests in src/rc_test.go that lock in the promised behavior.
odeke-em added a commit that referenced this issue Dec 18, 2016
Fixes #778.

Now allows you to restructure your .driverc separating
commands into sections and having different clauses.

Please note:
* You can put multiple commands in the same
section by using separator "/". See the rules at
https://github.com/odeke-em/namespace/blob/0ab79ba44f1328b1ec75ea985ad5c338ba3d56a6/ns.go#L3-L14

* Overwriting of command rules is
command_section > global
and
commandX_higher_line > commandX_lower_line
where lines are natural numbers that are ascending

* Exhibits:
This is a sample of a .driverc that I've just defined that has flexible
behavior in different sections.

```
id=true # Will be applied globally unless overwritten in a command

[global]
depth=10 # The depth to use if not defined

[pull/list]
depth=2 # The depth to be used for pull or list

[push]
verbose=true # verbose is only true for push

[list]
long=true # Allow long output for list
```

And see the tests in src/rc_test.go that lock in the promised behavior.
odeke-em added a commit that referenced this issue Dec 18, 2016
Fixes #778.

Now allows you to restructure your .driverc separating
commands into sections and having different clauses.

Please note:
* You can put multiple commands in the same
section by using separator "/". See the rules at
https://github.com/odeke-em/namespace/blob/0ab79ba44f1328b1ec75ea985ad5c338ba3d56a6/ns.go#L3-L14

* Overwriting of command rules is
command_section > global
and
commandX_higher_line > commandX_lower_line
where lines are natural numbers that are ascending

* Exhibits:
This is a sample of a .driverc that I've just defined that has flexible
behavior in different sections.

```
id=true # Will be applied globally unless overwritten in a command

[global]
depth=10 # The depth to use if not defined

[pull/list]
depth=2 # The depth to be used for pull or list

[push]
verbose=true # verbose is only true for push

[list]
long=true # Allow long output for list
```

And see the tests in src/rc_test.go that lock in the promised behavior.
@jean-christophe-manciot
Copy link
Author

jean-christophe-manciot commented Dec 18, 2016

Nice ;)
I've read structured/sectioned .driverc configuration: I feel there might be a potential issue if the user inadvertently positions the [global] section below another [<command>] section: The options in the global section could override more specific ones, couldn't they?.

@odeke-em
Copy link
Owner

@jean-christophe-manciot it doesn't matter actually, placing a command below the other only overwrites if those commands are the same, otherwise we follow the overwriting precedence
mentioned ie [definedNamespace] > [global].

For example:

[global]
depth=10
[global]
depth=-1
[global]
depth=1

the depth in namespace global will be 1 at the end. That's different from

[push]
depth=12
[global]
depth=1
[global]
depth=3

the depth in namespace global will be 3 at the end, the depth in namespace push will be 12

@jean-christophe-manciot
Copy link
Author

jean-christophe-manciot commented Dec 18, 2016

Also, are only <key>=<value> lines supported, or can we mimic all options available on the CLI?
For instance:
[share]
emails=drive-mailing-list@gmail.com,odeke@ualberta.ca message="Here is the drive code" role=reader,commenter type=user
[diff]
skip-content-check

@odeke-em
Copy link
Owner

odeke-em commented Jan 7, 2017

@jean-christophe-manciot on a side note, thank you very much for your contributions! I made a release and gave you a shoutout, that's the least I could do https://github.com/odeke-em/drive/releases/tag/v0.3.9.

@odeke-em
Copy link
Owner

odeke-em commented Jan 7, 2017

In regards to your request in #778 (comment), that'd be nice. Please file an issue and we'll put it on the plate for v0.4.0 as an enhancement.

@jean-christophe-manciot
Copy link
Author

@odeke-em thanks for such detailed release notes. Very helpful. This project is definitely on the right track :-)
The enhancement proposal is available here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants