|
| 1 | +/* |
| 2 | + * jPOS Project [http://jpos.org] |
| 3 | + * Copyright (C) 2000-2017 jPOS Software SRL |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Affero General Public License as |
| 7 | + * published by the Free Software Foundation, either version 3 of the |
| 8 | + * License, or (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU Affero General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Affero General Public License |
| 16 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | + |
| 19 | +package org.jpos.q2.cli; |
| 20 | + |
| 21 | +import org.jpos.core.DefaultLUHNCalculator; |
| 22 | +import org.jpos.q2.CLICommand; |
| 23 | +import org.jpos.q2.CLIContext; |
| 24 | + |
| 25 | +@SuppressWarnings("unused") |
| 26 | +public class CALCLUHN implements CLICommand { |
| 27 | + public void exec(CLIContext ctx, String[] args) throws Exception { |
| 28 | + if (args.length < 2) { |
| 29 | + ctx.println (String.format ("Usage: %span(s)", args[0])); |
| 30 | + return; |
| 31 | + } |
| 32 | + DefaultLUHNCalculator calc = new DefaultLUHNCalculator(); |
| 33 | + for (int i=1; i<args.length; i++) |
| 34 | + ctx.println(String.format("%s%c", args[i], calc.calculate(args[i]))); |
| 35 | + } |
| 36 | +} |
0 commit comments