Skip to content

Add ability to pass in a context file#116

Closed
emonty wants to merge 1 commit intocookiecutter:masterfrom
emonty:take-json-arg
Closed

Add ability to pass in a context file#116
emonty wants to merge 1 commit intocookiecutter:masterfrom
emonty:take-json-arg

Conversation

@emonty
Copy link
Copy Markdown

@emonty emonty commented Nov 13, 2013

If cookiecutter is used inside of a project creation automation, you
want to not only give --no-input, but also supply input values other
than the ones in the default file.

Add a command line option, --context-file, which allows overriding the
default location for default values.

If cookiecutter is used inside of a project creation automation, you
want to not only give --no-input, but also supply input values other
than the ones in the default file.

Add a command line option, --context-file, which allows overriding the
default location for default values.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a trailing ,.
Which fixes the build failure: https://travis-ci.org/audreyr/cookiecutter/jobs/13916746

@michaeljoseph
Copy link
Copy Markdown
Contributor

Could we please change this a bit, I think it's cleaner for cookiecutter.main.cookiecutter to take an extra_context dict, with the file handling happening just in the CLI bits?

@michaeljoseph
Copy link
Copy Markdown
Contributor

Ah, that's #75.
Could you change this to just include the new cli argument please?

@michaeljoseph
Copy link
Copy Markdown
Contributor

Ugh, or maybe you need to wait and see if #100 wins @audreyr's ❤️

@audreyfeldroy
Copy link
Copy Markdown
Member

@emonty thanks for submitting, and @michaeljoseph thanks for all your help. Yeah, something along these lines would probably good.

Sigh, I need to squeeze out some time to study #75 and #100 and figure out what to do - work, the upcoming book, and wedding planning pressure are just killing me right now. @michaeljoseph any thoughts about one vs the other?

@michaeljoseph
Copy link
Copy Markdown
Contributor

@audreyr #75 is solid, has tests and just updates the internal cookiecutter API to take a context dict (which is what I care about for michaeljoseph/changes#35 and is the simplest change).
#100 is essentially a dupe of #75 but allows you to bypass user config lookups (#100 doesn't have tests either).
This one (#116) needs to be cleaned up and updated to just add the CLI option (@emonty 🔔) and depend on either #100 or #75 for the change to cookiecutter.main.cookiecutter.

Ok, so I think 👍 for #75 and #116 and then a re-work of #100 to support the user config bypass case?

@michaeljoseph
Copy link
Copy Markdown
Contributor

@emonty 🔔

@shaleh
Copy link
Copy Markdown

shaleh commented Jul 8, 2014

I forked this repo specifically to add this feature then found it sitting here moribund. What is the status? Can I help?

@audreyfeldroy
Copy link
Copy Markdown
Member

@shaleh @emonty I apologize for the delay, my fault. I just added @michaeljoseph and @pydanny as core committers and we're going to get through the backlog.

I'm marking this for 0.8.0 for now since #75 is marked as 0.8.0. @michaeljoseph you know the most about this area, so I'll let you take the lead on merging as per your earlier comments.

@pydanny Before @michaeljoseph merges this for 0.8.0, will you have time to work on a 0.7.2 patch release for fixing the Windows tests? Or should we do 0.8.0 this week-ish and the Windows tests in an 0.8.1 patch next week?

@shaleh
Copy link
Copy Markdown

shaleh commented Jul 8, 2014

No worries @audreyr. I went through and commented on a few open tickets today. The team can ping me for input or testing.

@pydanny
Copy link
Copy Markdown
Member

pydanny commented Jul 8, 2014

@audreyr Unless I get a Windows expert to help out, I simply can't predict when the tests on Windows will be fixed. Therefore, I recommend:

  • We go for the 0.8.0 release this week-ish
  • Make getting the Windows fixed an absolute priority before any new features are added post-0.8.0.

@ryanolson
Copy link
Copy Markdown

This is very similar to Issue #187 and Issue #199; however the behaviors are slightly different.

In this case, --context-file overrides the values in cookiecutter.json which then can be overridden by values in default_context.

cookiecutter.json <= context_file < default_context.

The most truthy values are in default_context. I'm not sure that is what we want. Projects like Ansible have the command-line parameters be the most truthy values overriding all other paths.

The #199 case, --parameters applies the user parameters after default_context. It also enforces cookiecutter.json has the truth regarding the keys for the project. This is important if the template changes the variable definitions, in which case an out-of-date parameters.json file will throw an error.

cookiecutter.json < default_context < user_parameters

@michaeljoseph
Copy link
Copy Markdown
Contributor

👀 #260

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

Labels

enhancement This issue/PR relates to a feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants