You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@taverna.apache.org by menaka121 <gi...@git.apache.org> on 2015/06/07 19:58:42 UTC

[GitHub] incubator-taverna-language pull request: Taverna Language Command ...

GitHub user menaka121 opened a pull request:

    https://github.com/apache/incubator-taverna-language/pull/1

    Taverna Language Command line tool

    This is a basic prototype of the commands of the tool with some tests for check the functionality.
    Please check this and give me the feed-backs/ suggestions.
    Menaka Madushanka

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/menaka121/incubator-taverna-language master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-taverna-language/pull/1.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1
    
----
commit 6f11622606076179c3f7b6130a376ab538c87da7
Author: Menaka <me...@gmail.com>
Date:   2015-05-29T19:40:55Z

    JCommander dependancy added

commit 18a3c12f9bd593c4e49929b6d9d5ed99d974c24c
Author: Menaka <me...@gmail.com>
Date:   2015-06-07T16:13:41Z

    pom updated

commit 0d8202bf328f00c86b9e4f3dd1ccf0ffb4a09378
Author: Menaka <me...@gmail.com>
Date:   2015-06-07T16:22:31Z

    Basic Commands

commit e3aea177629942277d29c1e64a59bdf4d0f1fc62
Author: Menaka <me...@gmail.com>
Date:   2015-06-07T16:31:55Z

    Test

commit 1c723309c8a355904e64cb1b60cecb5154d027b1
Author: Menaka <me...@gmail.com>
Date:   2015-06-07T17:10:12Z

    Test

commit 130978f028aafaaed3384d760bd5124ccc412a7e
Author: Menaka <me...@gmail.com>
Date:   2015-06-07T17:51:33Z

    Minor edits

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-language pull request: Taverna Language Command ...

Posted by stain <gi...@git.apache.org>.
Github user stain commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-language/pull/1#discussion_r31896539
  
    --- Diff: taverna-language-commandline/src/main/java/org/apache/taverna/commandline/CommandLineTool.java ---
    @@ -0,0 +1,252 @@
    +package org.apache.taverna.commandline;
    --- End diff --
    
    Could you set the package name something like
    `org.apache.taverna.language.commandline` 
    ? To avoid confusion with the executeworkflow-commandline, which we are keeping outside for now. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-language pull request: Taverna Language Command ...

Posted by stain <gi...@git.apache.org>.
Github user stain commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-language/pull/1#discussion_r31896381
  
    --- Diff: taverna-language-commandline/src/main/java/org/apache/taverna/commandline/CommandLineTool.java ---
    @@ -0,0 +1,252 @@
    +package org.apache.taverna.commandline;
    +
    +
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * 
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + * 
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +
    +import io.airlift.airline.Arguments;
    +import io.airlift.airline.Cli;
    +import io.airlift.airline.Cli.CliBuilder;
    +import io.airlift.airline.Command;
    +import io.airlift.airline.Help;
    +import io.airlift.airline.Option;
    +
    +import java.io.File;
    +import java.util.List;
    +
    +import javax.inject.Inject;
    +
    +import com.google.common.base.Joiner;
    +import com.google.common.collect.Lists;
    +
    +
    +/*
    + * The command line options for convert, validate and inspect workflows.
    + * Use the airlift/airline library
    + * Author: Menaka Madushanka <me...@gmail.com>
    --- End diff --
    
    While you should be recognized as an author through the git commits, in Apache projects we prefer not to to put "Author" information into the Javadoc, as it could indicate ownership - anyone in the project would be free to fix/update "your" command line tool after acceptance. Would you be OK to remove the Author: line..?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-language pull request: Taverna Language Command ...

Posted by stain <gi...@git.apache.org>.
Github user stain commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-language/pull/1#discussion_r31896413
  
    --- Diff: taverna-language-commandline/src/main/java/org/apache/taverna/commandline/CommandLineTool.java ---
    @@ -0,0 +1,252 @@
    +package org.apache.taverna.commandline;
    +
    +
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * 
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + * 
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +
    +import io.airlift.airline.Arguments;
    +import io.airlift.airline.Cli;
    +import io.airlift.airline.Cli.CliBuilder;
    +import io.airlift.airline.Command;
    +import io.airlift.airline.Help;
    +import io.airlift.airline.Option;
    +
    +import java.io.File;
    +import java.util.List;
    +
    +import javax.inject.Inject;
    +
    +import com.google.common.base.Joiner;
    +import com.google.common.collect.Lists;
    +
    +
    +/*
    + * The command line options for convert, validate and inspect workflows.
    + * Use the airlift/airline library
    + * Author: Menaka Madushanka <me...@gmail.com>
    + * */
    +
    +public class CommandLineTool {
    +	
    +	private Cli<TvnLangTool> parser(){
    +		CliBuilder<TvnLangTool> build = Cli.<TvnLangTool>builder("tavlang")
    +				.withDescription("Convert, manage workflows")
    +				.withDefaultCommand(HelpCommand.class)
    +				.withCommand(CommandConvert.class)
    +				.withCommand(HelpCommand.class)
    +				.withCommand(CommandInspect.class)
    +				.withCommand(CommandValidate.class)
    +				.withCommand(CommandVersion.class);
    +		
    +		return build.build();
    +	}
    +
    +	public CommandLineTool(){};
    +	public void parse(String... args)
    +    {
    +        System.out.println("$ tavlang " + Joiner.on(" ").join(args));
    +        TvnLangTool command = parser().parse(args);
    +        command.execute();
    +        System.out.println();
    +    }
    +	
    +	public static abstract class TvnLangTool{
    +
    +		public abstract void execute();
    +	}
    +	
    +	//placeholder for output file types
    +	public static class Filetypes{
    +		@Option(name= "-wfdesc", description="Convert the workflow file to wfdesc-turtle")
    +		public static boolean isWfdesc = false;
    +		
    +		@Option(name="-wfbundel", description="Convert the workflow file to wfbundel")
    +		public static boolean isWfbundel = false;
    +		
    +		@Option(name =  "-robundel", description = "Convert given bundel in to Research Object bundel")
    +		public static boolean isRo = false;
    +		
    +		@Option(name= "-structure", description = "Convert the workflow into *.structure")
    --- End diff --
    
    I like the style of the `airline` library - good choice!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-language pull request: Taverna Language Command ...

Posted by menaka121 <gi...@git.apache.org>.
Github user menaka121 commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-language/pull/1#discussion_r31879122
  
    --- Diff: taverna-language-commandline/src/main/java/org/apache/taverna/commandline/CommandLineTool.java ---
    @@ -0,0 +1,252 @@
    +package org.apache.taverna.commandline;
    +
    +
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * 
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + * 
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +
    +import io.airlift.airline.Arguments;
    +import io.airlift.airline.Cli;
    +import io.airlift.airline.Cli.CliBuilder;
    +import io.airlift.airline.Command;
    +import io.airlift.airline.Help;
    +import io.airlift.airline.Option;
    +
    +import java.io.File;
    +import java.util.List;
    +
    +import javax.inject.Inject;
    +
    +import com.google.common.base.Joiner;
    +import com.google.common.collect.Lists;
    +
    +
    +/*
    + * The command line options for convert, validate and inspect workflows.
    + * Use the airlift/airline library
    + * Author: Menaka Madushanka <me...@gmail.com>
    + * */
    +
    +public class CommandLineTool {
    +	
    +	private Cli<TvnLangTool> parser(){
    +		CliBuilder<TvnLangTool> build = Cli.<TvnLangTool>builder("tavlang")
    +				.withDescription("Convert, manage workflows")
    +				.withDefaultCommand(HelpCommand.class)
    +				.withCommand(CommandConvert.class)
    +				.withCommand(HelpCommand.class)
    +				.withCommand(CommandInspect.class)
    +				.withCommand(CommandValidate.class)
    +				.withCommand(CommandVersion.class);
    +		
    +		return build.build();
    +	}
    +
    +	public CommandLineTool(){};
    +	public void parse(String... args)
    +    {
    +        System.out.println("$ tavlang " + Joiner.on(" ").join(args));
    +        TvnLangTool command = parser().parse(args);
    +        command.execute();
    +        System.out.println();
    +    }
    +	
    +	public static abstract class TvnLangTool{
    +
    +		public abstract void execute();
    +	}
    +	
    +	//placeholder for output file types
    +	public static class Filetypes{
    +		@Option(name= "-wfdesc", description="Convert the workflow file to wfdesc-turtle")
    +		public static boolean isWfdesc = false;
    +		
    +		@Option(name="-wfbundel", description="Convert the workflow file to wfbundel")
    +		public static boolean isWfbundel = false;
    +		
    +		@Option(name =  "-robundel", description = "Convert given bundel in to Research Object bundel")
    +		public static boolean isRo = false;
    +		
    +		@Option(name= "-structure", description = "Convert the workflow into *.structure")
    +		public static boolean isStructure = false;
    +
    +		@Option(name = "-json", description = "Convert the workflow into json")
    +		public static boolean isJson = false;
    +		
    +		//The tool can only handle one output format at a time.
    +		//Return the file type which is selected
    +		public static String isTrue(){
    +			if(isWfdesc) return "wfdesc";
    +			else if(isWfbundel) return "wfbundel";
    +			else if(isRo) return "ro";
    +			else if(isStructure) return "structure";
    +			else if(isJson) return "json";
    +			else return null;
    +		}
    +		
    +	}
    +	
    +	public static class Inspect{
    +		@Option(name = "-servicetypes", description = "List the service types")
    +		public static boolean servicetypes = false;
    +		
    +		@Option(name = "-processornames", description = "List the processor names")
    +		public static boolean processor = false;
    +		
    +		public String getWay(){
    +			if(servicetypes) return "servicetypes";
    +			else if (processor) return "processornames";
    +			else return null;
    +		}
    +		
    +	}
    +	
    +	
    +	//Placeholder for optional parameters: Ex: -i, -o 
    +	public static class Optional{
    +		
    +		
    +		@Option(name={"-l", "--log"}, description = "Save a results to a file")
    +		public boolean log = false;
    +		
    +		//The input file or directory
    +		@Option(name = {"-i", "--input"}, description="Input file/ file dir for convertion")
    +		public static String in_file_dir;
    +		
    +		//The out put file or directory. When this is set, all the converted files will be saved into the directory that specified.
    +		@Option(name = {"-o", "--output"}, description="Output file/ directory")
    +		public static String out_file_dir;
    +		
    +		public static String getInFile(){
    +			return in_file_dir;
    +		}
    +		
    +		public static String getOutFile(){
    +			return out_file_dir;
    +		}
    +
    +	}
    +	
    +	@Command(name = "help", description = "Display help information about Tvarna")
    +	public static class HelpCommand extends TvnLangTool{
    +		@Inject
    +	    public Help help;
    +
    +	    @Override
    +	    public void execute(){
    +	    	help.call();
    +	    }
    +	}
    +	
    +	//Command for convert workflows
    +	@Command(name="convert", description="Convert the given workflow")
    +	public static class CommandConvert extends TvnLangTool{
    +		@Inject
    +		Optional optional = new Optional();
    +		
    +		@Inject
    +		Filetypes filetypes = new Filetypes();
    +		
    +		@Arguments(usage = "<output format> <input files> ", description = "List of files to be converted.\n "
    +				+ "Give the list of files to be converted without -i/-o and the converted files will be saved in to /converted folder in the same dir")
    +        public final List<String> files = Lists.newArrayList();
    +		
    +		//When this is true, the command will run recursively in a directory.
    +		@Option(name={"-r", "--recursive"}, description="Execute the command recursively")
    +		public boolean recurse = false;
    +		
    +		//Option for validate the given workflow when converting
    +		@Option(name = {"-V", "--validate"}, description="Validate the workflow before convert")
    +		public boolean validate = false;
    +		
    +		@Override
    +		public void execute(){
    --- End diff --
    
    The execution of the command will go from here....



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-language pull request: Taverna Language Command ...

Posted by stain <gi...@git.apache.org>.
Github user stain commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-language/pull/1#discussion_r31896445
  
    --- Diff: taverna-language-commandline/src/test/java/org/apache/commandline/test/CommandLineTest.java ---
    @@ -0,0 +1,30 @@
    +package org.apache.commandline.test;
    --- End diff --
    
    Wrong package name.. and could you add the Apache license header here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---