aboutsummaryrefslogtreecommitdiff
path: root/bdep
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-05-15 13:59:41 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2019-05-16 15:36:35 +0200
commit7cc6a852a24914253f6fa158b30fd250915c128b (patch)
treeefd867fd1bd03ef67ab912ad6a58eef408dc971d /bdep
parent15beec8cf83c7d479c50f7bfbc9e05e1803686cc (diff)
Make bdep-new add README.md template
Can suppressed with the new no-readme --type suboption.
Diffstat (limited to 'bdep')
-rw-r--r--bdep/new-types.hxx18
-rw-r--r--bdep/new.cli22
-rw-r--r--bdep/new.cxx78
3 files changed, 92 insertions, 26 deletions
diff --git a/bdep/new-types.hxx b/bdep/new-types.hxx
index 96aaa7c..d1ef18f 100644
--- a/bdep/new-types.hxx
+++ b/bdep/new-types.hxx
@@ -59,7 +59,7 @@ namespace bdep
case type::empty: return "empty";
}
- return string (); // Should never reach.
+ return std::string (); // Should never reach.
}
friend ostream&
@@ -92,17 +92,23 @@ namespace bdep
cmd_new_lang_template (): lang (cxx) {}
const std::string
- string () const
+ string (bool lower = false) const
{
using lang = cmd_new_lang_template;
switch (*this)
{
- case lang::c: return "c";
- case lang::cxx: return "c++";
+ case lang::c: return lower ? "c" : "C";
+ case lang::cxx: return lower ? "c++" : "C++";
}
- return string (); // Should never reach.
+ return std::string (); // Should never reach.
+ }
+
+ friend ostream&
+ operator<< (ostream& os, const cmd_new_lang_template& l)
+ {
+ return os << l.string ();
}
};
@@ -139,7 +145,7 @@ namespace bdep
case vcs::none: return "none";
}
- return string (); // Should never reach.
+ return std::string (); // Should never reach.
}
};
diff --git a/bdep/new.cli b/bdep/new.cli
index 1e206df..6bab278 100644
--- a/bdep/new.cli
+++ b/bdep/new.cli
@@ -130,6 +130,10 @@ namespace bdep
Add support for unit testing.|
+ \li|\n\ \ \ \cb{no-readme}
+
+ Don't add \cb{README.md}.|
+
\li|\n\ \ \ \cb{alt-naming}
Use the alternative build file/directory naming scheme.||
@@ -153,6 +157,10 @@ namespace bdep
Don't add support for generating the version header.|
+ \li|\n\ \ \ \cb{no-readme}
+
+ Don't add \cb{README.md}.|
+
\li|\n\ \ \ \cb{alt-naming}
Use the alternative build file/directory naming scheme.||
@@ -168,6 +176,10 @@ namespace bdep
Don't add support for testing.|
+ \li|\n\ \ \ \cb{no-readme}
+
+ Don't add \cb{README.md}.|
+
\li|\n\ \ \ \cb{alt-naming}
Use the alternative build file/directory naming scheme.||
@@ -178,7 +190,11 @@ namespace bdep
An empty project that can be filled with packages (see
\cb{--package}). Note that the project language is ignored for this
- project type.||
+ project type. Recognized empty project options:|
+
+ \li|\n\ \ \ \cb{no-readme}
+
+ Don't add \cb{README.md}.||
The project language can be specified with the \c{\b{--lang}|\b{-l}}
option. Valid values for this option and their semantics are described
@@ -286,6 +302,7 @@ namespace bdep
{
bool no-tests;
bool unit-tests;
+ bool no-readme;
bool alt-naming;
};
@@ -294,17 +311,20 @@ namespace bdep
bool no-tests;
bool unit-tests;
bool no-version;
+ bool no-readme;
bool alt-naming;
};
class cmd_new_bare_options
{
bool no-tests;
+ bool no-readme;
bool alt-naming;
};
class cmd_new_empty_options
{
+ bool no-readme;
};
// --lang options
diff --git a/bdep/new.cxx b/bdep/new.cxx
index 11ac8f4..88563bc 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -46,7 +46,7 @@ namespace bdep
fail << "both --no-init and " << m << " specified";
if (const char* n = (o.no_init () ? "--no-init" :
- m ? m : nullptr))
+ m ? m : nullptr))
{
if (ca) fail << "both " << n << " and --config-add specified";
if (cc) fail << "both " << n << " and --config-create specified";
@@ -74,26 +74,29 @@ namespace bdep
// will most likely be wrong). All this seems reasonable for what this
// mode is expected to be used ("end-product" kind of projects).
//
- bool altn (false); // alt-naming
- bool itest (false); // !no-tests
- bool utest (false); // unit-tests
- bool ver (false); // !no-version
+ bool readme (false); // !no-readme
+ bool altn (false); // alt-naming
+ bool itest (false); // !no-tests
+ bool utest (false); // unit-tests
+ bool ver (false); // !no-version
switch (t)
{
case type::exe:
{
- altn = t.exe_opt.alt_naming ();
- itest = !t.exe_opt.no_tests ();
- utest = t.exe_opt.unit_tests ();
+ readme = !t.exe_opt.no_readme () && !o.subdirectory ();
+ altn = t.exe_opt.alt_naming ();
+ itest = !t.exe_opt.no_tests ();
+ utest = t.exe_opt.unit_tests ();
break;
}
case type::lib:
{
- altn = t.lib_opt.alt_naming ();
- itest = !t.lib_opt.no_tests () && !o.subdirectory ();
- utest = t.lib_opt.unit_tests ();
- ver = !t.lib_opt.no_version () && !o.subdirectory ();
+ readme = !t.lib_opt.no_readme () && !o.subdirectory ();
+ altn = t.lib_opt.alt_naming ();
+ itest = !t.lib_opt.no_tests () && !o.subdirectory ();
+ utest = t.lib_opt.unit_tests ();
+ ver = !t.lib_opt.no_version () && !o.subdirectory ();
break;
}
case type::bare:
@@ -101,8 +104,9 @@ namespace bdep
if (o.subdirectory ())
fail << "cannot create bare source subdirectory";
- altn = t.bare_opt.alt_naming ();
- itest = !t.bare_opt.no_tests ();
+ readme = !t.bare_opt.no_readme ();
+ altn = t.bare_opt.alt_naming ();
+ itest = !t.bare_opt.no_tests ();
break;
}
case type::empty:
@@ -111,6 +115,7 @@ namespace bdep
o.package () ? "package" : nullptr))
fail << "cannot create empty " << w;
+ readme = !t.empty_opt.no_readme ();
break;
}
}
@@ -468,6 +473,36 @@ namespace bdep
os.close ();
}
+ // README.md
+ //
+ if (readme)
+ {
+ os.open (f = out / "README.md");
+ switch (t)
+ {
+ case type::exe:
+ case type::lib:
+ {
+ // @@ Maybe we should generate a "Hello, World" description and
+ // usage example as a guide, at least for a library?
+
+ os << "# " << n << " - " << l << " " << t << endl
+ << endl
+ << "TODO" << endl;
+ break;
+ }
+ case type::bare:
+ case type::empty:
+ {
+ os << "# " << n << endl
+ << endl
+ << "TODO" << endl;
+ break;
+ }
+ }
+ os.close ();
+ }
+
if (t == type::empty)
break;
@@ -528,9 +563,11 @@ namespace bdep
<< "version: 0.1.0-a.0.z" << endl;
if (pn)
os << "project: " << *pn << endl;
- os << "summary: " << s << " " << t << endl
- << "license: TODO" << endl
- << "url: https://example.org/" << (pn ? pn->string () : n) << endl
+ os << "summary: " << s << " " << l << " " << t << endl
+ << "license: TODO" << endl;
+ if (readme)
+ os << "description-file: README.md" << endl;
+ os << "url: https://example.org/" << (pn ? pn->string () : n) << endl
<< "email: " << pe << endl
<< "depends: * build2 >= 0.10.0" << endl
<< "depends: * bpkg >= 0.10.0" << endl
@@ -727,7 +764,10 @@ namespace bdep
if (!sub)
{
os.open (f = out / buildfile_file);
- os << "./: {*/ -" << build_dir.posix_representation () << "} manifest" << endl;
+
+ os << "./: {*/ -" << build_dir.posix_representation () << "}" <<
+ (readme ? " doc{README.md}" : "") << " manifest" << endl;
+
if (itest && t == type::lib) // Have tests/ subproject.
os << endl
<< "# Don't install tests." << endl
@@ -1621,7 +1661,7 @@ namespace bdep
add_var ("base", move (b));
add_var ("stem", move (s));
add_var ("type", t.string ());
- add_var ("lang", l.string ());
+ add_var ("lang", l.string (true /* lower */));
add_var ("vcs", vc.string ());
add_var ("root", prj.string ());