Re: [PATCH 1 of 3 PoC] cli: initial introduction of 'kallithea' command

2018-09-30 Thread Mads Kiilerich

On 9/26/18 9:03 PM, Thomas De Schampheleire wrote:

El mié., 26 sept. 2018 a las 13:00, Mads Kiilerich
() escribió:

One concern could be that this command "isn't Kallithea". Kallithea
"itself" must be run from gearbox or another web/wsgi server. That can
be confusing. The command is more about Kallithea
management/install/setup/control/something.

Yes, I have had the same consideration. I had a look at 'Flask', a
micro web framework (which is also using click), and they are also
using 'flask' for the command-line tool although it is not 'Flask',
the project.
We could use 'kallithea-cli' as name, or kallithea-setup, whatever you prefer.



I also don't know the right answer. If you already had the same concerns 
and thought about it, your answer is probably as good as any other.




(But I guess, 'serve' could perhaps also be built in ...)

You mean wrapping 'gearbox serve' within the new CLI command?
One reason against it would be that 'gearbox serve' is just one way of
starting the serving. It does not apply when using Apache, uwsgi, or
other approaches.



Yes. Just like the gearbox serve command also only is one of many ways 
to serve wsgi.


But it could perhaps be placed under a "development" or "source" sub 
command. A command that also monitor file system and rebuild front-end 
code automatically. And perhaps also take care of building/updating 
localization.


/Mads

___
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general


Re: [PATCH 1 of 3 PoC] cli: initial introduction of 'kallithea' command

2018-09-26 Thread Thomas De Schampheleire
El mié., 26 sept. 2018 a las 13:00, Mads Kiilerich
() escribió:
>
> On 9/24/18 10:45 PM, Thomas De Schampheleire wrote:
> > # HG changeset patch
> > # User Thomas De Schampheleire 
> > # Date 1537819512 -7200
> > #  Mon Sep 24 22:05:12 2018 +0200
> > # Node ID dd4da443ed94fd93ca09d5f5fd9cf1b2c72b3cc4
> > # Parent  a73e2822dd99eb5bdc551174d9d4f9c76f8f1667
> > cli: initial introduction of 'kallithea' command
> >
> > This commit adds a command 'kallithea' that intends to replace the existing
> > set of 'gearbox' commands that relate to setting up kallithea. Gearbox
> > would still be used for 'gearbox serve', but other commands like
> > 'make-config', 'setup-db', etc. would be converted to 'kallithea' commands.
>
>
> I like this. I like to try to get this thing right, so our releases
> don't change the same thing over and over, but once it has been changed,
> we get it right and stick to it.
>
> One concern could be that this command "isn't Kallithea". Kallithea
> "itself" must be run from gearbox or another web/wsgi server. That can
> be confusing. The command is more about Kallithea
> management/install/setup/control/something.

Yes, I have had the same consideration. I had a look at 'Flask', a
micro web framework (which is also using click), and they are also
using 'flask' for the command-line tool although it is not 'Flask',
the project.
We could use 'kallithea-cli' as name, or kallithea-setup, whatever you prefer.

>
> (But I guess, 'serve' could perhaps also be built in ...)

You mean wrapping 'gearbox serve' within the new CLI command?
One reason against it would be that 'gearbox serve' is just one way of
starting the serving. It does not apply when using Apache, uwsgi, or
other approaches.

>
>
> > The python package 'Click' is used to generate the CLI. Using decorators,
> > this package makes it very easy to generate a CLI out of simple methods.
> > See: http://click.pocoo.org/6/
>
>
> I haven't used that package before, but it seems solid.

To be clear: for me it's also the first time.

>
>
> > Using Gearbox for custom commands is possible, but documentation on this
> > topic is limited. As the added value of Gearbox for that use case is not
> > clear, we can well switch to something else if it seems better/easier.
>
>
> Gearbox is closely related to TurboGears ... and TurboGeards upstream
> have been quite helpful. Should we reach out with our concerns before
> switching? I don't know how that could help, but it seems like the right
> thing to do.

You're right. I added Alessandro Molina to this mail thread.

Alessandro: background is this series:
https://lists.sfconservancy.org/pipermail/kallithea-general/2018q3/002753.html
which introduces a CLI tool to implement our custom Kallithea CLI
commands, using the Click python library.
This CLI tool would cover the commands that we are currently running
via gearbox, i.e. things in 'kallithea/lib/paster_commands/*.py'
From my current point of view, there is no practical benefit on using
gearbox for these custom commands, rather than something else. As it
happens, Click has as main purpose providing a CLI, and feels more
intuitive to me.
Perhaps I'm missing something, so your feedback is very welcome!

Best regards,
Thomas
___
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general


Re: [PATCH 1 of 3 PoC] cli: initial introduction of 'kallithea' command

2018-09-26 Thread Mads Kiilerich

On 9/24/18 10:45 PM, Thomas De Schampheleire wrote:

# HG changeset patch
# User Thomas De Schampheleire 
# Date 1537819512 -7200
#  Mon Sep 24 22:05:12 2018 +0200
# Node ID dd4da443ed94fd93ca09d5f5fd9cf1b2c72b3cc4
# Parent  a73e2822dd99eb5bdc551174d9d4f9c76f8f1667
cli: initial introduction of 'kallithea' command

This commit adds a command 'kallithea' that intends to replace the existing
set of 'gearbox' commands that relate to setting up kallithea. Gearbox
would still be used for 'gearbox serve', but other commands like
'make-config', 'setup-db', etc. would be converted to 'kallithea' commands.



I like this. I like to try to get this thing right, so our releases 
don't change the same thing over and over, but once it has been changed, 
we get it right and stick to it.


One concern could be that this command "isn't Kallithea". Kallithea 
"itself" must be run from gearbox or another web/wsgi server. That can 
be confusing. The command is more about Kallithea 
management/install/setup/control/something.


(But I guess, 'serve' could perhaps also be built in ...)



The python package 'Click' is used to generate the CLI. Using decorators,
this package makes it very easy to generate a CLI out of simple methods.
See: http://click.pocoo.org/6/



I haven't used that package before, but it seems solid.



Using Gearbox for custom commands is possible, but documentation on this
topic is limited. As the added value of Gearbox for that use case is not
clear, we can well switch to something else if it seems better/easier.



Gearbox is closely related to TurboGears ... and TurboGeards upstream 
have been quite helpful. Should we reach out with our concerns before 
switching? I don't know how that could help, but it seems like the right 
thing to do.




diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -60,6 +60,7 @@ requirements = [
  "mercurial >= 4.1.1, < 4.8",
  "decorator >= 3.3.2, < 4.4",
  "Paste >= 2.0.3, < 3",
+"Click >= 6.7, < 7",
  ]
  
  if sys.version_info < (2, 7):

@@ -151,6 +152,7 @@ setuptools.setup(
  kallithea-api =kallithea.bin.kallithea_api:main
  kallithea-gist =   kallithea.bin.kallithea_gist:main
  kallithea-config = kallithea.bin.kallithea_config:main
+kallithea =kallithea.bin.kallithea_cli:cli



I forgot about these other commands we have ... I guess I should review 
these too ...


/Mads
___
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general


[PATCH 1 of 3 PoC] cli: initial introduction of 'kallithea' command

2018-09-24 Thread Thomas De Schampheleire
# HG changeset patch
# User Thomas De Schampheleire 
# Date 1537819512 -7200
#  Mon Sep 24 22:05:12 2018 +0200
# Node ID dd4da443ed94fd93ca09d5f5fd9cf1b2c72b3cc4
# Parent  a73e2822dd99eb5bdc551174d9d4f9c76f8f1667
cli: initial introduction of 'kallithea' command

This commit adds a command 'kallithea' that intends to replace the existing
set of 'gearbox' commands that relate to setting up kallithea. Gearbox
would still be used for 'gearbox serve', but other commands like
'make-config', 'setup-db', etc. would be converted to 'kallithea' commands.

The python package 'Click' is used to generate the CLI. Using decorators,
this package makes it very easy to generate a CLI out of simple methods.
See: http://click.pocoo.org/6/

Using Gearbox for custom commands is possible, but documentation on this
topic is limited. As the added value of Gearbox for that use case is not
clear, we can well switch to something else if it seems better/easier.

diff --git a/kallithea/bin/kallithea_cli.py b/kallithea/bin/kallithea_cli.py
new file mode 100644
--- /dev/null
+++ b/kallithea/bin/kallithea_cli.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+import click
+
+@click.group()
+def cli():
+"""Various commands to set up a Kallithea instance."""
+pass
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -60,6 +60,7 @@ requirements = [
 "mercurial >= 4.1.1, < 4.8",
 "decorator >= 3.3.2, < 4.4",
 "Paste >= 2.0.3, < 3",
+"Click >= 6.7, < 7",
 ]
 
 if sys.version_info < (2, 7):
@@ -151,6 +152,7 @@ setuptools.setup(
 kallithea-api =kallithea.bin.kallithea_api:main
 kallithea-gist =   kallithea.bin.kallithea_gist:main
 kallithea-config = kallithea.bin.kallithea_config:main
+kallithea =kallithea.bin.kallithea_cli:cli
 
 [paste.app_factory]
 main = kallithea.config.middleware:make_app
___
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general